aboutsummaryrefslogtreecommitdiffstats
path: root/core/types/dkg/dkg.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-12-19 17:16:40 +0800
committerGitHub <noreply@github.com>2018-12-19 17:16:40 +0800
commitc7b4045802450df361216d9e7da3ec318e67cc34 (patch)
treec4060817a54e5cf455e830b21e6a91b9fc11004f /core/types/dkg/dkg.go
parent7bafefa5c70a26a28636123cb2b6598eea3ed380 (diff)
downloadtangerine-consensus-c7b4045802450df361216d9e7da3ec318e67cc34.tar
tangerine-consensus-c7b4045802450df361216d9e7da3ec318e67cc34.tar.gz
tangerine-consensus-c7b4045802450df361216d9e7da3ec318e67cc34.tar.bz2
tangerine-consensus-c7b4045802450df361216d9e7da3ec318e67cc34.tar.lz
tangerine-consensus-c7b4045802450df361216d9e7da3ec318e67cc34.tar.xz
tangerine-consensus-c7b4045802450df361216d9e7da3ec318e67cc34.tar.zst
tangerine-consensus-c7b4045802450df361216d9e7da3ec318e67cc34.zip
core: Add a `MPKReady` so `MasterPublicKey` cannot be added afterwards (#375)
* Add type DKGReady * Add DKGReady to interface and state * DKG will wait for MPK to be ready before running * Modify test * Check if self's MPK is registered * Add test for delay add MPK * Rename Ready to MPKReady
Diffstat (limited to 'core/types/dkg/dkg.go')
-rw-r--r--core/types/dkg/dkg.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/types/dkg/dkg.go b/core/types/dkg/dkg.go
index cecc4f1..f021d1b 100644
--- a/core/types/dkg/dkg.go
+++ b/core/types/dkg/dkg.go
@@ -167,6 +167,27 @@ type PartialSignature struct {
Signature crypto.Signature `json:"signature"`
}
+// MPKReady describe a dig ready message in DKG protocol.
+type MPKReady struct {
+ ProposerID types.NodeID `json:"proposer_id"`
+ Round uint64 `json:"round"`
+ Signature crypto.Signature `json:"signature"`
+}
+
+func (ready *MPKReady) String() string {
+ return fmt.Sprintf("DKGMPKReady{RP:%s Round:%d}",
+ ready.ProposerID.String()[:6],
+ ready.Round)
+}
+
+// Equal check equality of two MPKReady instances.
+func (ready *MPKReady) Equal(other *MPKReady) bool {
+ return ready.ProposerID.Equal(other.ProposerID) &&
+ ready.Round == other.Round &&
+ ready.Signature.Type == other.Signature.Type &&
+ bytes.Compare(ready.Signature.Signature, other.Signature.Signature) == 0
+}
+
// Finalize describe a dig finalize message in DKG protocol.
type Finalize struct {
ProposerID types.NodeID `json:"proposer_id"`