Merge pull request #48 from simple-rules/ricl-txgen

get client port into configr
pull/50/head
Richard Liu 6 years ago committed by GitHub
commit 82df392ac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      client/txgen/main.go
  2. 11
      configr/main.go

@ -164,17 +164,6 @@ UTXOLOOP:
return txs, crossTxs 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. // A utility func that counts the total number of utxos in a pool.
func countNumOfUtxos(utxoPool *blockchain.UTXOPool) int { func countNumOfUtxos(utxoPool *blockchain.UTXOPool) int {
countAll := 0 countAll := 0
@ -232,7 +221,7 @@ func main() {
} }
// Client/txgenerator server node setup // Client/txgenerator server node setup
clientPort := getClientPort(&config) clientPort := configr.GetClientPort(&config)
consensusObj := consensus.NewConsensus("0", clientPort, "0", nil, p2p.Peer{}) consensusObj := consensus.NewConsensus("0", clientPort, "0", nil, p2p.Peer{})
clientNode := node.New(consensusObj) clientNode := node.New(consensusObj)

@ -57,6 +57,17 @@ func GetClientPeer(config *[][]string) *p2p.Peer {
return nil 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 // Parse the config file and return a 2d array containing the file data
func ReadConfigFile(filename string) ([][]string, error) { func ReadConfigFile(filename string) ([][]string, error) {
file, err := os.Open(filename) file, err := os.Open(filename)

Loading…
Cancel
Save