p2p

package
v0.0.0-...-5d05a64 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRequest = 40 // Size has to be calculated based on maximum possible values on Queue

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockAndPeer

type BlockAndPeer struct {
	// contains filtered or unexported fields
}

type Downloader

type Downloader struct {
	// contains filtered or unexported fields
}

func NewDownloader

func NewDownloader(c *chain.Chain) (d *Downloader)

func (*Downloader) AddEpochBlockHashesResponse

func (d *Downloader) AddEpochBlockHashesResponse(data *protos.EpochBlockHashesResponse, peer *Peer)

func (*Downloader) AddPeer

func (d *Downloader) AddPeer(p *Peer)

func (*Downloader) BlockDownloader

func (d *Downloader) BlockDownloader(targetSlotNumbers []*HashesAndPeerInfo,
	lastBlockHeaderToDownload common.Hash, peerGroup []*Peer)

func (*Downloader) Consumer

func (d *Downloader) Consumer(lastBlockHeaderToDownload common.Hash, peerGroup []*Peer)

func (*Downloader) DownloadMonitor

func (d *Downloader) DownloadMonitor()

func (*Downloader) Exit

func (d *Downloader) Exit()

func (*Downloader) Initialize

func (d *Downloader) Initialize(peerGroup []*Peer,
	startingNonFinalizedEpoch uint64, finalizedHeaderHash common.Hash)

func (*Downloader) RemovePeer

func (d *Downloader) RemovePeer(p *Peer) bool

func (*Downloader) RequestForBlock

func (d *Downloader) RequestForBlock(targetSlotNumbers []*HashesAndPeerInfo,
	nextIndexForRequest int, numberOfRequests int) (int, int, error)

type EBHRespInfo

type EBHRespInfo struct {
	Data      *protos.EpochBlockHashesResponse
	Timestamp uint64
}

type HashesAndPeerInfo

type HashesAndPeerInfo struct {
	// contains filtered or unexported fields
}

type MRDataConn

type MRDataConn struct {
	// contains filtered or unexported fields
}

type MessageReceipt

type MessageReceipt struct {
	// contains filtered or unexported fields
}

func CreateMR

func CreateMR() (mr *MessageReceipt)

func (*MessageReceipt) Get

func (mr *MessageReceipt) Get(messageHash []byte) *protos.LegacyMessage

func (*MessageReceipt) GetHashMsg

func (mr *MessageReceipt) GetHashMsg(msgHash string) (value *protos.LegacyMessage, ok bool)

func (*MessageReceipt) GetRequestedHash

func (mr *MessageReceipt) GetRequestedHash(msgHash string) (value *MessageRequest, ok bool)

func (*MessageReceipt) IsRequested

func (mr *MessageReceipt) IsRequested(msgHashBytes common.Hash, peer *Peer) bool

func (*MessageReceipt) Register

func (mr *MessageReceipt) Register(msgHash string, msg *protos.LegacyMessage)

func (*MessageReceipt) RemoveRequestedHash

func (mr *MessageReceipt) RemoveRequestedHash(msgHash string)

type MessageRequest

type MessageRequest struct {
	// contains filtered or unexported fields
}

func CreateMessageRequest

func CreateMessageRequest(mrData *protos.MRData, peer *Peer) (messageRequest *MessageRequest)

func (*MessageRequest) GetPeer

func (messageRequest *MessageRequest) GetPeer() *Peer

func (*MessageRequest) GetRequested

func (messageRequest *MessageRequest) GetRequested() bool

func (*MessageRequest) SetPeer

func (messageRequest *MessageRequest) SetPeer(peer *Peer, value bool)

func (*MessageRequest) SetRequested

func (messageRequest *MessageRequest) SetRequested(value bool)

type Msg

type Msg struct {
	ReceivedAt time.Time
	// contains filtered or unexported fields
}

type OrderedMap

type OrderedMap struct {
	// contains filtered or unexported fields
}

func (*OrderedMap) Delete

func (o *OrderedMap) Delete(k string)

func (*OrderedMap) Get

func (o *OrderedMap) Get(k string) *MessageRequest

func (*OrderedMap) Put

func (o *OrderedMap) Put(k string, v *MessageRequest)

type OutgoingMessage

type OutgoingMessage struct {
	// contains filtered or unexported fields
}

func CreateOutgoingMessage

func CreateOutgoingMessage(priority uint64, msg *protos.LegacyMessage) *OutgoingMessage

func (*OutgoingMessage) IsExpired

func (o *OutgoingMessage) IsExpired() bool

type Peer

type Peer struct {
	// contains filtered or unexported fields
}

func (*Peer) ChainState

func (p *Peer) ChainState() *protos.NodeChainState

func (*Peer) Disconnect

func (p *Peer) Disconnect()

func (*Peer) GetEpochToBeRequested

func (p *Peer) GetEpochToBeRequested() uint64

func (*Peer) GetTotalStakeAmount

func (p *Peer) GetTotalStakeAmount() []byte

func (*Peer) HandleAttestTransaction

func (p *Peer) HandleAttestTransaction(msg *Msg, txData *protos.ProtocolTransactionData) error

func (*Peer) HandleBlock

func (p *Peer) HandleBlock(pbBlock *protos.Block)

func (*Peer) HandleBlockForAttestation

func (p *Peer) HandleBlockForAttestation(pbBlock *protos.Block, signature []byte)

func (*Peer) HandleChainState

func (p *Peer) HandleChainState(nodeChainState *protos.NodeChainState)

func (*Peer) HandleTransaction

func (p *Peer) HandleTransaction(msg *Msg, txData *protos.Transaction) error

func (*Peer) ID

func (p *Peer) ID() string

func (*Peer) IP

func (p *Peer) IP() string

func (*Peer) IncreaseEpochToBeRequested

func (p *Peer) IncreaseEpochToBeRequested()

func (*Peer) ReadMsg

func (p *Peer) ReadMsg() (msg *Msg, size uint32, err error)

func (*Peer) Send

func (p *Peer) Send(msg *Msg) error

func (*Peer) SendEBHReq

func (p *Peer) SendEBHReq(epoch uint64, finalizedHeaderHash []byte) error

func (*Peer) SendFetchBlock

func (p *Peer) SendFetchBlock(blockHeaderHash common.Hash) error

func (*Peer) SendNext

func (p *Peer) SendNext() error

func (*Peer) SendPeerList

func (p *Peer) SendPeerList()

func (*Peer) SendSync

func (p *Peer) SendSync()

func (*Peer) SendVersion

func (p *Peer) SendVersion()

func (*Peer) UpdateEpochToBeRequested

func (p *Peer) UpdateEpochToBeRequested(epoch uint64)

type PeerIPWithPLData

type PeerIPWithPLData struct {
	PLData *protos.PLData
	// contains filtered or unexported fields
}

type PriorityQueue

type PriorityQueue []*OutgoingMessage

func (PriorityQueue) Full

func (pq PriorityQueue) Full() bool

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (*PriorityQueue) RemoveExpiredMessages

func (pq *PriorityQueue) RemoveExpiredMessages()

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type RequestTracker

type RequestTracker struct {
	// contains filtered or unexported fields
}

func NewRequestTracker

func NewRequestTracker() *RequestTracker

func (*RequestTracker) AddPeerRequest

func (r *RequestTracker) AddPeerRequest(headerHash string, peer *Peer)

func (*RequestTracker) GetPeerByHeaderHash

func (r *RequestTracker) GetPeerByHeaderHash(headerHash string) (*Peer, bool)

func (*RequestTracker) GetSequenceByIndex

func (r *RequestTracker) GetSequenceByIndex(index int) string

func (*RequestTracker) RemoveFirstElementFromSequence

func (r *RequestTracker) RemoveFirstElementFromSequence()

func (*RequestTracker) RemoveRequestKey

func (r *RequestTracker) RemoveRequestKey(headerHash string)

func (*RequestTracker) TotalRequest

func (r *RequestTracker) TotalRequest() int

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(chain *chain.Chain) (*Server, error)

func (*Server) BlockReceived

func (srv *Server) BlockReceived(peer *Peer, b *block.Block)

func (*Server) BroadcastAttestationTransaction

func (srv *Server) BroadcastAttestationTransaction(attestTx *transactions.Attest,
	slotNumber uint64, blockProposer []byte,
	parentHeaderHash common.Hash, partialBlockSigningHash common.Hash)

func (*Server) BroadcastBlock

func (srv *Server) BroadcastBlock(block *block.Block)

func (*Server) BroadcastBlockForAttestation

func (srv *Server) BroadcastBlockForAttestation(block *block.Block, signature []byte)

func (*Server) ConnectPeer

func (srv *Server) ConnectPeer(dest string) error

func (*Server) ConnectPeers

func (srv *Server) ConnectPeers() error

func (*Server) GetAttestationReceivedForBlock

func (srv *Server) GetAttestationReceivedForBlock() chan *transactions.Attest

func (*Server) GetBlockReceivedForAttestation

func (srv *Server) GetBlockReceivedForAttestation() chan *block.Block

func (*Server) GetRegisterAndBroadcastChan

func (srv *Server) GetRegisterAndBroadcastChan() chan *messages.RegisterMessage

func (*Server) HandleTransaction

func (srv *Server) HandleTransaction(mrDataConn *MRDataConn)

func (*Server) RequestFullMessage

func (srv *Server) RequestFullMessage(mrData *protos.MRData)

func (*Server) Start

func (srv *Server) Start(keys crypto.PrivKey) (err error)

func (*Server) Stop

func (srv *Server) Stop() (err error)

func (*Server) UpdatePeerList

func (srv *Server) UpdatePeerList(p *PeerIPWithPLData) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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