Documentation ¶
Index ¶
- type ArgPeerShardMapper
- type PeerShardMapper
- func (psm *PeerShardMapper) EpochStartAction(hdr data.HeaderHandler)
- func (psm *PeerShardMapper) EpochStartPrepare(metaHdr data.HeaderHandler, _ data.BodyHandler)
- func (psm *PeerShardMapper) GetPeerInfo(pid core.PeerID) core.P2PPeerInfo
- func (psm *PeerShardMapper) IsInterfaceNil() bool
- func (psm *PeerShardMapper) NotifyOrder() uint32
- func (psm *PeerShardMapper) UpdatePeerIDInfo(pid core.PeerID, pk []byte, shardID uint32)
- func (psm *PeerShardMapper) UpdatePeerIdSubType(pid core.PeerID, peerSubType core.P2PPeerSubType)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgPeerShardMapper ¶ added in v1.2.0
type ArgPeerShardMapper struct { PeerIdPkCache storage.Cacher FallbackPkShardCache storage.Cacher FallbackPidShardCache storage.Cacher NodesCoordinator sharding.NodesCoordinator PreferredPeersHolder p2p.PreferredPeersHolderHandler StartEpoch uint32 }
ArgPeerShardMapper is the initialization structure for the PeerShardMapper implementation
type PeerShardMapper ¶
type PeerShardMapper struct {
// contains filtered or unexported fields
}
PeerShardMapper stores the mappings between peer IDs and shard IDs Both public key and peer id are verified before they are appended in this cache. In time, the current node will learn a large majority (or even the whole network) of the nodes that make up the network. The public key provided by this map is then fed to the nodes coordinator that will output the shard id in which that public key resides. This component also have a reversed lookup map that will ensure that there won't be unlimited peer ids with the same public key. This will prevent eclipse attacks. The mapping between shard id and public key is done by the nodes coordinator implementation but the fallbackPkShard fallback map is only used whenever nodes coordinator has a wrong view about the peers in a shard.
func NewPeerShardMapper ¶
func NewPeerShardMapper(arg ArgPeerShardMapper) (*PeerShardMapper, error)
NewPeerShardMapper creates a new peerShardMapper instance
func (*PeerShardMapper) EpochStartAction ¶ added in v0.0.5
func (psm *PeerShardMapper) EpochStartAction(hdr data.HeaderHandler)
EpochStartAction is the method called whenever an action needs to be undertaken in respect to the epoch change
func (*PeerShardMapper) EpochStartPrepare ¶ added in v0.0.5
func (psm *PeerShardMapper) EpochStartPrepare(metaHdr data.HeaderHandler, _ data.BodyHandler)
EpochStartPrepare is the method called whenever an action needs to be undertaken in respect to the epoch preparation change
func (*PeerShardMapper) GetPeerInfo ¶
func (psm *PeerShardMapper) GetPeerInfo(pid core.PeerID) core.P2PPeerInfo
GetPeerInfo returns the corresponding shard ID of a given peer ID. It also returns the type of provided peer
func (*PeerShardMapper) IsInterfaceNil ¶
func (psm *PeerShardMapper) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*PeerShardMapper) NotifyOrder ¶ added in v0.0.5
func (psm *PeerShardMapper) NotifyOrder() uint32
NotifyOrder returns the notification order of this component
func (*PeerShardMapper) UpdatePeerIDInfo ¶ added in v1.2.3
func (psm *PeerShardMapper) UpdatePeerIDInfo(pid core.PeerID, pk []byte, shardID uint32)
UpdatePeerIDInfo updates the public keys and the shard ID for the peer IDin the corresponding maps It also uses the intermediate pkPeerId cache that will prevent having thousands of peer ID's with the same Elrond PK that will make the node prone to an eclipse attack
func (*PeerShardMapper) UpdatePeerIdSubType ¶ added in v1.2.0
func (psm *PeerShardMapper) UpdatePeerIdSubType(pid core.PeerID, peerSubType core.P2PPeerSubType)
UpdatePeerIdSubType updates the peerIdSubType search map containing peer IDs and peer subtypes