github.com/neatlab/neatio@v1.7.3-0.20220425043230-d903e92fcc75/network/p2p/validator_nodeinfo.go (about) 1 package p2p 2 3 import ( 4 "time" 5 6 "github.com/neatlab/neatio/network/p2p/discover" 7 "github.com/neatlab/neatio/utilities/common" 8 "github.com/neatlab/neatio/utilities/rlp" 9 "golang.org/x/crypto/sha3" 10 ) 11 12 type P2PValidator struct { 13 ChainId string 14 Address common.Address 15 } 16 17 type P2PValidatorNodeInfo struct { 18 Node discover.Node 19 TimeStamp time.Time 20 Validator P2PValidator 21 Original bool 22 } 23 24 func (vni *P2PValidatorNodeInfo) Hash() common.Hash { 25 return rlpHash(vni) 26 } 27 28 func rlpHash(x interface{}) (h common.Hash) { 29 hw := sha3.NewLegacyKeccak256() 30 rlp.Encode(hw, x) 31 hw.Sum(h[:0]) 32 return h 33 }