diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-08-20 13:16:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-20 13:16:53 +0800 |
commit | d9ba7986a975615fb10790cfd448c48c89c1a7b3 (patch) | |
tree | 2741f02522707ba9de43928dda67abf1368b1ec3 /simulation/simulation.go | |
parent | fd8358a607ccd564a5e8158451a5d9ef9cb7b55b (diff) | |
download | dexon-consensus-d9ba7986a975615fb10790cfd448c48c89c1a7b3.tar dexon-consensus-d9ba7986a975615fb10790cfd448c48c89c1a7b3.tar.gz dexon-consensus-d9ba7986a975615fb10790cfd448c48c89c1a7b3.tar.bz2 dexon-consensus-d9ba7986a975615fb10790cfd448c48c89c1a7b3.tar.lz dexon-consensus-d9ba7986a975615fb10790cfd448c48c89c1a7b3.tar.xz dexon-consensus-d9ba7986a975615fb10790cfd448c48c89c1a7b3.tar.zst dexon-consensus-d9ba7986a975615fb10790cfd448c48c89c1a7b3.zip |
simulation: taken network latency model into consideration in TCP mode (#68)
- Clone block once for each broadcast
- Add network latency model for TCPNetwork
- Fix map concurrent write
Diffstat (limited to 'simulation/simulation.go')
-rw-r--r-- | simulation/simulation.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/simulation/simulation.go b/simulation/simulation.go index cc5ac10..bd69fb5 100644 --- a/simulation/simulation.go +++ b/simulation/simulation.go @@ -34,7 +34,14 @@ func Run(configPath string) { networkType := cfg.Networking.Type - var vs []*Validator + var ( + vs []*Validator + networkModel = &NormalNetwork{ + Sigma: cfg.Networking.Sigma, + Mean: cfg.Networking.Mean, + LossRateValue: cfg.Networking.LossRateValue, + } + ) if networkType == config.NetworkTypeFake || networkType == config.NetworkTypeTCPLocal { @@ -42,11 +49,6 @@ func Run(configPath string) { var network Network if networkType == config.NetworkTypeFake { - networkModel := &NormalNetwork{ - Sigma: cfg.Networking.Sigma, - Mean: cfg.Networking.Mean, - LossRateValue: cfg.Networking.LossRateValue, - } network = NewFakeNetwork(networkModel) for i := 0; i < cfg.Validator.Num; i++ { @@ -66,7 +68,7 @@ func Run(configPath string) { } wg.Add(1) go func() { - network := NewTCPNetwork(true, cfg.Networking.PeerServer) + network := NewTCPNetwork(true, cfg.Networking.PeerServer, networkModel) network.Start() lock.Lock() defer lock.Unlock() @@ -86,7 +88,7 @@ func Run(configPath string) { if err != nil { panic(err) } - network := NewTCPNetwork(false, cfg.Networking.PeerServer) + network := NewTCPNetwork(false, cfg.Networking.PeerServer, networkModel) network.Start() v := NewValidator(prv, eth.SigToPub, cfg.Validator, network) go v.Run() |