networksharding

package
v1.6.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgPeerShardMapper

type ArgPeerShardMapper struct {
	PeerIdPkCache         storage.Cacher
	FallbackPkShardCache  storage.Cacher
	FallbackPidShardCache storage.Cacher
	NodesCoordinator      nodesCoordinator.NodesCoordinator
	PreferredPeersHolder  p2p.PreferredPeersHolderHandler
}

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) 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

func (psm *PeerShardMapper) NotifyOrder() uint32

NotifyOrder returns the notification order of this component

func (*PeerShardMapper) PutPeerIdShardId

func (psm *PeerShardMapper) PutPeerIdShardId(pid core.PeerID, shardId uint32)

PutPeerIdShardId puts the peer ID and shard ID into fallback cache in case it does not exist

func (*PeerShardMapper) PutPeerIdSubType

func (psm *PeerShardMapper) PutPeerIdSubType(pid core.PeerID, peerSubType core.P2PPeerSubType)

PutPeerIdSubType puts the peerIdSubType search map containing peer IDs and peer subtypes

func (*PeerShardMapper) UpdatePeerIDInfo

func (psm *PeerShardMapper) UpdatePeerIDInfo(pid core.PeerID, pk []byte, shardID uint32)

UpdatePeerIDInfo updates the public keys and the shard ID for the peer ID in the corresponding maps It also uses the intermediate pkPeerId cache that will prevent having thousands of peer ID's with the same MultiversX PK that will make the node prone to an eclipse attack

func (*PeerShardMapper) UpdatePeerIDPublicKeyPair

func (psm *PeerShardMapper) UpdatePeerIDPublicKeyPair(pid core.PeerID, pk []byte)

UpdatePeerIDPublicKeyPair updates the public key - peer ID pair in the corresponding maps It also uses the intermediate pkPeerId cache that will prevent having thousands of peer ID's with the same MultiversX PK that will make the node prone to an eclipse attack

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL