diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-02-22 13:14:55 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:22 +0800 |
commit | 2354d4aa747616a8fd4fb9482ada8042fd362139 (patch) | |
tree | 46fe0953c0258591c2cd415c3760764ff613a5bb /vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go | |
parent | 81193a683d6328b627ee0e5f0f3689b3473e29ea (diff) | |
download | go-tangerine-2354d4aa747616a8fd4fb9482ada8042fd362139.tar go-tangerine-2354d4aa747616a8fd4fb9482ada8042fd362139.tar.gz go-tangerine-2354d4aa747616a8fd4fb9482ada8042fd362139.tar.bz2 go-tangerine-2354d4aa747616a8fd4fb9482ada8042fd362139.tar.lz go-tangerine-2354d4aa747616a8fd4fb9482ada8042fd362139.tar.xz go-tangerine-2354d4aa747616a8fd4fb9482ada8042fd362139.tar.zst go-tangerine-2354d4aa747616a8fd4fb9482ada8042fd362139.zip |
core: Remove K, Phi and NumChains from Governance (#198)
* change default sync_core.sh
* vendor: sync to latest core
* core: Remove K, Phi and NumChain
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go')
-rw-r--r-- | vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go index efe846755..db58168a2 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go @@ -163,6 +163,64 @@ func (c *Complaint) Equal(other *Complaint) bool { bytes.Compare(c.Signature.Signature, other.Signature.Signature) == 0 } +type rlpComplaint struct { + ProposerID types.NodeID + Round uint64 + IsNack bool + PrivateShare []byte + Signature crypto.Signature +} + +// EncodeRLP implements rlp.Encoder +func (c *Complaint) EncodeRLP(w io.Writer) error { + if c.IsNack() { + return rlp.Encode(w, rlpComplaint{ + ProposerID: c.ProposerID, + Round: c.Round, + IsNack: true, + PrivateShare: c.PrivateShare.ProposerID.Hash[:], + Signature: c.Signature, + }) + } + prvShare, err := rlp.EncodeToBytes(&c.PrivateShare) + if err != nil { + return err + } + return rlp.Encode(w, rlpComplaint{ + ProposerID: c.ProposerID, + Round: c.Round, + IsNack: false, + PrivateShare: prvShare, + Signature: c.Signature, + }) +} + +// DecodeRLP implements rlp.Decoder +func (c *Complaint) DecodeRLP(s *rlp.Stream) error { + var dec rlpComplaint + if err := s.Decode(&dec); err != nil { + return err + } + + var prvShare PrivateShare + if dec.IsNack { + copy(prvShare.ProposerID.Hash[:], dec.PrivateShare) + prvShare.Round = dec.Round + } else { + if err := rlp.DecodeBytes(dec.PrivateShare, &prvShare); err != nil { + return err + } + } + + *c = Complaint{ + ProposerID: dec.ProposerID, + Round: dec.Round, + PrivateShare: prvShare, + Signature: dec.Signature, + } + return nil +} + // PartialSignature describe a partial signature in DKG protocol. type PartialSignature struct { ProposerID types.NodeID `json:"proposer_id"` |