diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-07-23 09:40:42 +0800 |
---|---|---|
committer | missionliao <38416648+missionliao@users.noreply.github.com> | 2018-07-23 09:40:42 +0800 |
commit | 2970eb21ecf400bd4862a6a53062eedde52c0138 (patch) | |
tree | 31670e3f01bfa5f5036d0581b9e9a8d8336c3dde /simulation | |
parent | 828170980ad9dd439ebab3f51af930e75d636e12 (diff) | |
download | dexon-consensus-2970eb21ecf400bd4862a6a53062eedde52c0138.tar dexon-consensus-2970eb21ecf400bd4862a6a53062eedde52c0138.tar.gz dexon-consensus-2970eb21ecf400bd4862a6a53062eedde52c0138.tar.bz2 dexon-consensus-2970eb21ecf400bd4862a6a53062eedde52c0138.tar.lz dexon-consensus-2970eb21ecf400bd4862a6a53062eedde52c0138.tar.xz dexon-consensus-2970eb21ecf400bd4862a6a53062eedde52c0138.tar.zst dexon-consensus-2970eb21ecf400bd4862a6a53062eedde52c0138.zip |
simulation: fix tcp-local network simulation (#8)
* simulation: fix tcp-local network simulation
* fixup
Diffstat (limited to 'simulation')
-rw-r--r-- | simulation/peer-server.go | 2 | ||||
-rw-r--r-- | simulation/tcp-network.go | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/simulation/peer-server.go b/simulation/peer-server.go index 4a74fb7..90bcf33 100644 --- a/simulation/peer-server.go +++ b/simulation/peer-server.go @@ -68,7 +68,7 @@ func (p *PeerServer) Run(configPath string) { defer p.peersMu.Unlock() host, _, _ := net.SplitHostPort(r.RemoteAddr) - p.peers[id] = fmt.Sprintf("%s:%s", host, portString) + p.peers[id] = net.JoinHostPort(host, portString) log.Printf("Peer %s joined from %s", id, p.peers[id]) } diff --git a/simulation/tcp-network.go b/simulation/tcp-network.go index 7640480..02475e1 100644 --- a/simulation/tcp-network.go +++ b/simulation/tcp-network.go @@ -50,9 +50,13 @@ func NewTCPNetwork(local bool, peerServer string) *TCPNetwork { if !local { port = peerPort } + pServer := peerServer + if local { + pServer = "localhost" + } return &TCPNetwork{ local: local, - peerServer: peerServer, + peerServer: pServer, port: port, endpoints: make(map[types.ValidatorID]string), recieveChan: make(chan interface{}, msgBufferSize), |