aboutsummaryrefslogtreecommitdiffstats
path: root/core/types/dkg/dkg.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-04-15 11:44:04 +0800
committerGitHub <noreply@github.com>2019-04-15 11:44:04 +0800
commit79be89a6b0b1d24b889e7c9fe0244026af4d49d0 (patch)
treebacd2dd8a224d2cffbe9965439707df7fa2888de /core/types/dkg/dkg.go
parent7abe09214fbf04f9f1f7f4f6ec57cd1f924953d6 (diff)
downloadtangerine-consensus-79be89a6b0b1d24b889e7c9fe0244026af4d49d0.tar
tangerine-consensus-79be89a6b0b1d24b889e7c9fe0244026af4d49d0.tar.gz
tangerine-consensus-79be89a6b0b1d24b889e7c9fe0244026af4d49d0.tar.bz2
tangerine-consensus-79be89a6b0b1d24b889e7c9fe0244026af4d49d0.tar.lz
tangerine-consensus-79be89a6b0b1d24b889e7c9fe0244026af4d49d0.tar.xz
tangerine-consensus-79be89a6b0b1d24b889e7c9fe0244026af4d49d0.tar.zst
tangerine-consensus-79be89a6b0b1d24b889e7c9fe0244026af4d49d0.zip
core: Add DKGSuccess (#569)
* core: Add DKGSuccess * core: reset if not enough of dkg success
Diffstat (limited to 'core/types/dkg/dkg.go')
-rw-r--r--core/types/dkg/dkg.go34
1 files changed, 29 insertions, 5 deletions
diff --git a/core/types/dkg/dkg.go b/core/types/dkg/dkg.go
index 868f0da..cb921e5 100644
--- a/core/types/dkg/dkg.go
+++ b/core/types/dkg/dkg.go
@@ -242,6 +242,11 @@ func (c *Complaint) DecodeRLP(s *rlp.Stream) error {
return nil
}
+// IsNack returns true if it's a nack complaint in DKG protocol.
+func (c *Complaint) IsNack() bool {
+ return len(c.PrivateShare.Signature.Signature) == 0
+}
+
// PartialSignature describe a partial signature in DKG protocol.
type PartialSignature struct {
ProposerID types.NodeID `json:"proposer_id"`
@@ -251,7 +256,7 @@ type PartialSignature struct {
Signature crypto.Signature `json:"signature"`
}
-// MPKReady describe a dig ready message in DKG protocol.
+// MPKReady describe a dkg ready message in DKG protocol.
type MPKReady struct {
ProposerID types.NodeID `json:"proposer_id"`
Round uint64 `json:"round"`
@@ -275,7 +280,7 @@ func (ready *MPKReady) Equal(other *MPKReady) bool {
bytes.Compare(ready.Signature.Signature, other.Signature.Signature) == 0
}
-// Finalize describe a dig finalize message in DKG protocol.
+// Finalize describe a dkg finalize message in DKG protocol.
type Finalize struct {
ProposerID types.NodeID `json:"proposer_id"`
Round uint64 `json:"round"`
@@ -299,9 +304,28 @@ func (final *Finalize) Equal(other *Finalize) bool {
bytes.Compare(final.Signature.Signature, other.Signature.Signature) == 0
}
-// IsNack returns true if it's a nack complaint in DKG protocol.
-func (c *Complaint) IsNack() bool {
- return len(c.PrivateShare.Signature.Signature) == 0
+// Success describe a dkg success message in DKG protocol.
+type Success struct {
+ ProposerID types.NodeID `json:"proposer_id"`
+ Round uint64 `json:"round"`
+ Reset uint64 `json:"reset"`
+ Signature crypto.Signature `json:"signature"`
+}
+
+func (s *Success) String() string {
+ return fmt.Sprintf("DKGSuccess{SP:%s Round:%d Reset:%d}",
+ s.ProposerID.String()[:6],
+ s.Round,
+ s.Reset)
+}
+
+// Equal check equality of two Success instances.
+func (s *Success) Equal(other *Success) bool {
+ return s.ProposerID.Equal(other.ProposerID) &&
+ s.Round == other.Round &&
+ s.Reset == other.Reset &&
+ s.Signature.Type == other.Signature.Type &&
+ bytes.Compare(s.Signature.Signature, other.Signature.Signature) == 0
}
// GroupPublicKey is the result of DKG protocol.