diff --git a/benchmark.go b/benchmark.go index 78f1aed9f..6c130ecac 100644 --- a/benchmark.go +++ b/benchmark.go @@ -55,18 +55,6 @@ func getPeers(myIp, myPort, myShardId string, config *[][]string) []p2p.Peer { return peerList } -func getClientPeer(config *[][]string) *p2p.Peer { - for _, node := range *config { - ip, port, status := node[0], node[1], node[2] - if status != "client" { - continue - } - peer := p2p.Peer{Port: port, Ip: ip} - return &peer - } - return nil -} - func attackDetermination(attackedMode int) bool { switch attackedMode { case 0: @@ -146,7 +134,7 @@ func main() { // Current node. currentNode := node.New(consensus) // Create client peer. - clientPeer := getClientPeer(&config) + clientPeer := configreader.GetClientPeer(&config) // If there is a client configured in the node list. if clientPeer != nil { currentNode.ClientPeer = clientPeer diff --git a/configreader/main.go b/configreader/main.go index 7c6ac4e00..86e58de15 100644 --- a/configreader/main.go +++ b/configreader/main.go @@ -45,6 +45,18 @@ func GetLeadersAndShardIds(config *[][]string) ([]p2p.Peer, []uint32) { return peerList, shardIds } +func GetClientPeer(config *[][]string) *p2p.Peer { + for _, node := range *config { + ip, port, status := node[0], node[1], node[2] + if status != "client" { + continue + } + peer := p2p.Peer{Port: port, Ip: ip} + return &peer + } + return nil +} + // Parse the config file and return a 2d array containing the file data func ReadConfigFile(filename string) ([][]string, error) { file, err := os.Open(filename)