github.com/intfoundation/intchain@v0.0.0-20220727031208-4316ad31ca73/p2p/validator_nodeinfo.go (about)

     1  package p2p
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/intfoundation/intchain/common"
     7  	"github.com/intfoundation/intchain/p2p/discover"
     8  	"github.com/intfoundation/intchain/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  }