diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-10-05 22:10:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-05 22:10:55 +0800 |
commit | b74b8c092dcc10a7792d92c64c6dc22d94edb295 (patch) | |
tree | 25d249774f2e116c357674693dd4633c11c55582 /simulation | |
parent | a23f81165db3071131ef67e70a54bbc78b8a0af1 (diff) | |
download | tangerine-consensus-b74b8c092dcc10a7792d92c64c6dc22d94edb295.tar tangerine-consensus-b74b8c092dcc10a7792d92c64c6dc22d94edb295.tar.gz tangerine-consensus-b74b8c092dcc10a7792d92c64c6dc22d94edb295.tar.bz2 tangerine-consensus-b74b8c092dcc10a7792d92c64c6dc22d94edb295.tar.lz tangerine-consensus-b74b8c092dcc10a7792d92c64c6dc22d94edb295.tar.xz tangerine-consensus-b74b8c092dcc10a7792d92c64c6dc22d94edb295.tar.zst tangerine-consensus-b74b8c092dcc10a7792d92c64c6dc22d94edb295.zip |
core: General tsig (#177)
Diffstat (limited to 'simulation')
-rw-r--r-- | simulation/marshaller.go | 16 | ||||
-rw-r--r-- | simulation/network.go | 17 |
2 files changed, 33 insertions, 0 deletions
diff --git a/simulation/marshaller.go b/simulation/marshaller.go index cdf080b..d677c1f 100644 --- a/simulation/marshaller.go +++ b/simulation/marshaller.go @@ -63,6 +63,18 @@ func (m *jsonMarshaller) Unmarshal( break } msg = vote + case "block-randomness-request": + request := &types.AgreementResult{} + if err = json.Unmarshal(payload, request); err != nil { + break + } + msg = request + case "block-randomness-result": + result := &types.BlockRandomnessResult{} + if err = json.Unmarshal(payload, result); err != nil { + break + } + msg = result case "dkg-private-share": privateShare := &types.DKGPrivateShare{} if err = json.Unmarshal(payload, privateShare); err != nil { @@ -111,6 +123,10 @@ func (m *jsonMarshaller) Marshal(msg interface{}) ( msgType = "block" case *types.Vote: msgType = "vote" + case *types.AgreementResult: + msgType = "block-randomness-request" + case *types.BlockRandomnessResult: + msgType = "block-randomness-result" case *types.DKGPrivateShare: msgType = "dkg-private-share" case *types.DKGMasterPublicKey: diff --git a/simulation/network.go b/simulation/network.go index 0faacf7..ab3b4fa 100644 --- a/simulation/network.go +++ b/simulation/network.go @@ -132,6 +132,22 @@ func (n *network) BroadcastBlock(block *types.Block) { } } +// BroadcastRandomnessRequest implements core.Network interface. +func (n *network) BroadcastRandomnessRequest( + randRequest *types.AgreementResult) { + if err := n.trans.Broadcast(randRequest); err != nil { + panic(err) + } +} + +// BroadcastRandomnessResult implements core.Network interface. +func (n *network) BroadcastRandomnessResult( + randResult *types.BlockRandomnessResult) { + if err := n.trans.Broadcast(randResult); err != nil { + panic(err) + } +} + // broadcast message to all other nodes in the network. func (n *network) broadcast(message interface{}) { if err := n.trans.Broadcast(message); err != nil { @@ -199,6 +215,7 @@ func (n *network) run() { disp := func(e *test.TransportEnvelope) { switch e.Msg.(type) { case *types.Block, *types.Vote, + *types.AgreementResult, *types.BlockRandomnessResult, *types.DKGPrivateShare, *types.DKGPartialSignature: n.toConsensus <- e.Msg default: |