From ab73f27df2b9c5b4a868ff2efce5861b2db725d5 Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Thu, 26 Jul 2018 06:57:47 -0700 Subject: [PATCH] get client port into configr --- client/txgen/main.go | 13 +------------ configr/main.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/txgen/main.go b/client/txgen/main.go index 7d38c978e..f3b344c36 100644 --- a/client/txgen/main.go +++ b/client/txgen/main.go @@ -164,17 +164,6 @@ UTXOLOOP: return txs, crossTxs } -// Gets the port of the client node in the config -func getClientPort(config *[][]string) string { - for _, node := range *config { - _, port, status, _ := node[0], node[1], node[2], node[3] - if status == "client" { - return port - } - } - return "" -} - // A utility func that counts the total number of utxos in a pool. func countNumOfUtxos(utxoPool *blockchain.UTXOPool) int { countAll := 0 @@ -232,7 +221,7 @@ func main() { } // Client/txgenerator server node setup - clientPort := getClientPort(&config) + clientPort := configr.GetClientPort(&config) consensusObj := consensus.NewConsensus("0", clientPort, "0", nil, p2p.Peer{}) clientNode := node.New(consensusObj) diff --git a/configr/main.go b/configr/main.go index 1e0244924..0922f4f8f 100644 --- a/configr/main.go +++ b/configr/main.go @@ -57,6 +57,17 @@ func GetClientPeer(config *[][]string) *p2p.Peer { return nil } +// Gets the port of the client node in the config +func GetClientPort(config *[][]string) string { + for _, node := range *config { + _, port, status, _ := node[0], node[1], node[2], node[3] + if status == "client" { + return port + } + } + return "" +} + // Parse the config file and return a 2d array containing the file data func ReadConfigFile(filename string) ([][]string, error) { file, err := os.Open(filename)