update configread

pull/47/head
Richard Liu 6 years ago
parent 12c83d422c
commit a2873e54bc
  1. 14
      benchmark.go
  2. 12
      configreader/main.go

@ -55,18 +55,6 @@ func getPeers(myIp, myPort, myShardId string, config *[][]string) []p2p.Peer {
return peerList 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 { func attackDetermination(attackedMode int) bool {
switch attackedMode { switch attackedMode {
case 0: case 0:
@ -146,7 +134,7 @@ func main() {
// Current node. // Current node.
currentNode := node.New(consensus) currentNode := node.New(consensus)
// Create client peer. // Create client peer.
clientPeer := getClientPeer(&config) clientPeer := configreader.GetClientPeer(&config)
// If there is a client configured in the node list. // If there is a client configured in the node list.
if clientPeer != nil { if clientPeer != nil {
currentNode.ClientPeer = clientPeer currentNode.ClientPeer = clientPeer

@ -45,6 +45,18 @@ func GetLeadersAndShardIds(config *[][]string) ([]p2p.Peer, []uint32) {
return peerList, shardIds 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 // 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