diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-10-09 11:59:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-09 11:59:19 +0800 |
commit | db07d005e2e5a9208620a8d0e5fcaedeaa6ed644 (patch) | |
tree | 860c7a1c2f5d30296f66b07ed4e59117eb265eb7 /simulation | |
parent | 9267d50de25ddf0f280eee797e2030ea989294e4 (diff) | |
download | dexon-consensus-db07d005e2e5a9208620a8d0e5fcaedeaa6ed644.tar dexon-consensus-db07d005e2e5a9208620a8d0e5fcaedeaa6ed644.tar.gz dexon-consensus-db07d005e2e5a9208620a8d0e5fcaedeaa6ed644.tar.bz2 dexon-consensus-db07d005e2e5a9208620a8d0e5fcaedeaa6ed644.tar.lz dexon-consensus-db07d005e2e5a9208620a8d0e5fcaedeaa6ed644.tar.xz dexon-consensus-db07d005e2e5a9208620a8d0e5fcaedeaa6ed644.tar.zst dexon-consensus-db07d005e2e5a9208620a8d0e5fcaedeaa6ed644.zip |
core: Add round to DKG methods in gov. Change network interface name (#185)
Diffstat (limited to 'simulation')
-rw-r--r-- | simulation/governance.go | 17 | ||||
-rw-r--r-- | simulation/network.go | 4 | ||||
-rw-r--r-- | simulation/node.go | 6 |
3 files changed, 19 insertions, 8 deletions
diff --git a/simulation/governance.go b/simulation/governance.go index f22abce..2b0f56b 100644 --- a/simulation/governance.go +++ b/simulation/governance.go @@ -140,7 +140,11 @@ func (g *simGovernance) addNode(pubKey crypto.PublicKey) { } // AddDKGComplaint adds a DKGComplaint. -func (g *simGovernance) AddDKGComplaint(complaint *types.DKGComplaint) { +func (g *simGovernance) AddDKGComplaint( + round uint64, complaint *types.DKGComplaint) { + if round != complaint.Round { + return + } if g.IsDKGFinal(complaint.Round) { return } @@ -166,7 +170,10 @@ func (g *simGovernance) DKGComplaints(round uint64) []*types.DKGComplaint { // AddDKGMasterPublicKey adds a DKGMasterPublicKey. func (g *simGovernance) AddDKGMasterPublicKey( - masterPublicKey *types.DKGMasterPublicKey) { + round uint64, masterPublicKey *types.DKGMasterPublicKey) { + if round != masterPublicKey.Round { + return + } // TODO(jimmy-dexon): check if the input is valid. g.dkgMasterPublicKey[masterPublicKey.Round] = append( g.dkgMasterPublicKey[masterPublicKey.Round], masterPublicKey) @@ -186,7 +193,11 @@ func (g *simGovernance) DKGMasterPublicKeys( } // AddDKGFinalize adds a DKG finalize message. -func (g *simGovernance) AddDKGFinalize(final *types.DKGFinalize) { +func (g *simGovernance) AddDKGFinalize( + round uint64, final *types.DKGFinalize) { + if round != final.Round { + return + } // TODO(jimmy-dexon): check if the input is valid. if _, exist := g.dkgFinal[final.Round]; !exist { g.dkgFinal[final.Round] = make(map[types.NodeID]struct{}) diff --git a/simulation/network.go b/simulation/network.go index ab3b4fa..89b81ce 100644 --- a/simulation/network.go +++ b/simulation/network.go @@ -132,8 +132,8 @@ func (n *network) BroadcastBlock(block *types.Block) { } } -// BroadcastRandomnessRequest implements core.Network interface. -func (n *network) BroadcastRandomnessRequest( +// BroadcastAgreementResult implements core.Network interface. +func (n *network) BroadcastAgreementResult( randRequest *types.AgreementResult) { if err := n.trans.Broadcast(randRequest); err != nil { panic(err) diff --git a/simulation/node.go b/simulation/node.go index b90c1f8..a6d5b89 100644 --- a/simulation/node.go +++ b/simulation/node.go @@ -111,11 +111,11 @@ MainLoop: break MainLoop } case *types.DKGComplaint: - n.gov.AddDKGComplaint(val) + n.gov.AddDKGComplaint(val.Round, val) case *types.DKGMasterPublicKey: - n.gov.AddDKGMasterPublicKey(val) + n.gov.AddDKGMasterPublicKey(val.Round, val) case *types.DKGFinalize: - n.gov.AddDKGFinalize(val) + n.gov.AddDKGFinalize(val.Round, val) default: panic(fmt.Errorf("unexpected message from server: %v", val)) } |