aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/dexcon-simulation-peer-server/main.go7
-rw-r--r--simulation/peer-server.go2
-rw-r--r--simulation/tcp-network.go6
3 files changed, 13 insertions, 2 deletions
diff --git a/cmd/dexcon-simulation-peer-server/main.go b/cmd/dexcon-simulation-peer-server/main.go
index 326ae45..3e13262 100644
--- a/cmd/dexcon-simulation-peer-server/main.go
+++ b/cmd/dexcon-simulation-peer-server/main.go
@@ -19,6 +19,8 @@ package main
import (
"flag"
+ "log"
+ "os"
"github.com/dexon-foundation/dexon-consensus-core/simulation"
)
@@ -28,6 +30,11 @@ var configFile = flag.String("config", "", "path to simulation config file")
func main() {
flag.Parse()
+ if *configFile == "" {
+ log.Println("error: no config file specified")
+ os.Exit(1)
+ }
+
server := simulation.NewPeerServer()
server.Run(*configFile)
}
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),