aboutsummaryrefslogtreecommitdiffstats
path: root/core/types
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-09-20 09:09:37 +0800
committerGitHub <noreply@github.com>2018-09-20 09:09:37 +0800
commit421d72b2d796195178104a0eb1dedf319ba8664c (patch)
treef32f15c167989905494eca1891c3240b80dac1d6 /core/types
parent37f117d35c6617e1944d45e001e03813a6a278ed (diff)
downloaddexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.gz
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.bz2
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.lz
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.xz
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.zst
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.zip
Rename validator* to node* (#120)
Diffstat (limited to 'core/types')
-rw-r--r--core/types/block.go2
-rw-r--r--core/types/dkg.go8
-rw-r--r--core/types/node.go (renamed from core/types/validator.go)24
-rw-r--r--core/types/vote.go2
-rw-r--r--core/types/witness.go2
5 files changed, 19 insertions, 19 deletions
diff --git a/core/types/block.go b/core/types/block.go
index 61cb458..949876f 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -54,7 +54,7 @@ func NewBlock() (b *Block) {
// Block represents a single event broadcasted on the network.
type Block struct {
- ProposerID ValidatorID `json:"proposer_id"`
+ ProposerID NodeID `json:"proposer_id"`
ParentHash common.Hash `json:"parent_hash"`
Hash common.Hash `json:"hash"`
Position Position `json:"position"`
diff --git a/core/types/dkg.go b/core/types/dkg.go
index 7fb686c..78f4da6 100644
--- a/core/types/dkg.go
+++ b/core/types/dkg.go
@@ -24,7 +24,7 @@ import (
// DKGPrivateShare describe a secret share in DKG protocol.
type DKGPrivateShare struct {
- ProposerID ValidatorID `json:"proposer_id"`
+ ProposerID NodeID `json:"proposer_id"`
Round uint64 `json:"round"`
PrivateShare dkg.PrivateKey `json:"private_share"`
Signature crypto.Signature `json:"signature"`
@@ -32,7 +32,7 @@ type DKGPrivateShare struct {
// DKGMasterPublicKey decrtibe a master public key in DKG protocol.
type DKGMasterPublicKey struct {
- ProposerID ValidatorID `json:"proposer_id"`
+ ProposerID NodeID `json:"proposer_id"`
Round uint64 `json:"round"`
DKGID dkg.ID `json:"dkg_id"`
PublicKeyShares dkg.PublicKeyShares `json:"public_key_shares"`
@@ -41,7 +41,7 @@ type DKGMasterPublicKey struct {
// DKGComplaint describe a complaint in DKG protocol.
type DKGComplaint struct {
- ProposerID ValidatorID `json:"proposer_id"`
+ ProposerID NodeID `json:"proposer_id"`
Round uint64 `json:"round"`
PrivateShare DKGPrivateShare `json:"private_share"`
Signature crypto.Signature `json:"signature"`
@@ -49,7 +49,7 @@ type DKGComplaint struct {
// DKGPartialSignature describe a partial signature in DKG protocol.
type DKGPartialSignature struct {
- ProposerID ValidatorID `json:"proposerID"`
+ ProposerID NodeID `json:"proposerID"`
Round uint64 `json:"round"`
PartialSignature dkg.PartialSignature `json:"partial_signature"`
Signature crypto.Signature `json:"signature"`
diff --git a/core/types/validator.go b/core/types/node.go
index 5151a6d..8a856de 100644
--- a/core/types/validator.go
+++ b/core/types/node.go
@@ -24,33 +24,33 @@ import (
"github.com/dexon-foundation/dexon-consensus-core/crypto"
)
-// ValidatorID is the ID type for validators.
-type ValidatorID struct {
+// NodeID is the ID type for nodes.
+type NodeID struct {
common.Hash
}
-// NewValidatorID returns a ValidatorID with Hash set to the hash value of
+// NewNodeID returns a NodeID with Hash set to the hash value of
// public key.
-func NewValidatorID(pubKey crypto.PublicKey) ValidatorID {
- return ValidatorID{Hash: crypto.Keccak256Hash(pubKey.Bytes())}
+func NewNodeID(pubKey crypto.PublicKey) NodeID {
+ return NodeID{Hash: crypto.Keccak256Hash(pubKey.Bytes())}
}
-// Equal checks if the hash representation is the same ValidatorID.
-func (v ValidatorID) Equal(hash common.Hash) bool {
+// Equal checks if the hash representation is the same NodeID.
+func (v NodeID) Equal(hash common.Hash) bool {
return v.Hash == hash
}
-// ValidatorIDs implements sort.Interface for ValidatorID.
-type ValidatorIDs []ValidatorID
+// NodeIDs implements sort.Interface for NodeID.
+type NodeIDs []NodeID
-func (v ValidatorIDs) Len() int {
+func (v NodeIDs) Len() int {
return len(v)
}
-func (v ValidatorIDs) Less(i int, j int) bool {
+func (v NodeIDs) Less(i int, j int) bool {
return bytes.Compare([]byte(v[i].Hash[:]), []byte(v[j].Hash[:])) == -1
}
-func (v ValidatorIDs) Swap(i int, j int) {
+func (v NodeIDs) Swap(i int, j int) {
v[i], v[j] = v[j], v[i]
}
diff --git a/core/types/vote.go b/core/types/vote.go
index bae8f7d..e92aa67 100644
--- a/core/types/vote.go
+++ b/core/types/vote.go
@@ -38,7 +38,7 @@ const (
// Vote is the vote structure defined in Crypto Shuffle Algorithm.
type Vote struct {
- ProposerID ValidatorID `json:"proposer_id"`
+ ProposerID NodeID `json:"proposer_id"`
Type VoteType `json:"type"`
BlockHash common.Hash `json:"block_hash"`
Period uint64 `json:"period"`
diff --git a/core/types/witness.go b/core/types/witness.go
index 1e432f6..349c1ab 100644
--- a/core/types/witness.go
+++ b/core/types/witness.go
@@ -28,7 +28,7 @@ import (
// WitnessAck represents the acking to the compaction chain.
type WitnessAck struct {
- ProposerID ValidatorID `json:"proposer_id"`
+ ProposerID NodeID `json:"proposer_id"`
WitnessBlockHash common.Hash `json:"witness_block_hash"`
Hash common.Hash `json:"hash"`
// WitnessSignature is the signature of the hash value of BlockWitness.