diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-08-13 14:02:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-13 14:02:23 +0800 |
commit | 39e2ea5eb982007a7438198f6d633fe580a3fd1f (patch) | |
tree | cd87fe44352df53d04ebfab71daf62ce57d46d28 /core | |
parent | ef8eef3e341777adc00b87c2b226bffbe337ebf6 (diff) | |
download | dexon-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar dexon-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar.gz dexon-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar.bz2 dexon-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar.lz dexon-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar.xz dexon-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.tar.zst dexon-consensus-39e2ea5eb982007a7438198f6d633fe580a3fd1f.zip |
core: ValidatorID.Hash is the hash of public key. (#49)
Diffstat (limited to 'core')
-rw-r--r-- | core/types/validator.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/types/validator.go b/core/types/validator.go index 86c3acc..27a9acd 100644 --- a/core/types/validator.go +++ b/core/types/validator.go @@ -21,6 +21,7 @@ import ( "bytes" "github.com/dexon-foundation/dexon-consensus-core/common" + "github.com/dexon-foundation/dexon-consensus-core/crypto" ) // ValidatorID is the ID type for validators. @@ -28,6 +29,12 @@ type ValidatorID struct { common.Hash } +// NewValidatorID returns a ValidatorID with Hash set to the hash value of +// public key. +func NewValidatorID(pubKey crypto.PublicKey) ValidatorID { + return ValidatorID{Hash: crypto.Keccak256Hash(pubKey.Bytes())} +} + // ValidatorIDs implements sort.Interface for ValidatorID. type ValidatorIDs []ValidatorID |