networksharding

package
v1.0.143 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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(
	peerIdPk storage.Cacher,
	fallbackPkShard storage.Cacher,
	fallbackPidShard storage.Cacher,
	nodesCoordinator sharding.NodesCoordinator,
	epochStart uint32,
) (*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) UpdatePeerIdPublicKey

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

UpdatePeerIdPublicKey updates the peer ID - public key pair in the corresponding map 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) UpdatePeerIdShardId

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

UpdatePeerIdShardId updates the fallback search map containing peer IDs and shard IDs

func (*PeerShardMapper) UpdatePublicKeyShardId

func (psm *PeerShardMapper) UpdatePublicKeyShardId(pk []byte, shardId uint32)

UpdatePublicKeyShardId updates the fallback search map containing public key and shard IDs

Jump to

Keyboard shortcuts

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