Documentation ¶
Index ¶
- Constants
- type BlockAndPeer
- type DiscReason
- type Downloader
- func (d *Downloader) AddPeer(p *Peer)
- func (d *Downloader) AddPeerToTargetPeers(p *Peer)
- func (d *Downloader) BlockDownloader()
- func (d *Downloader) Consumer()
- func (d *Downloader) DownloadMonitor()
- func (d *Downloader) Exit()
- func (d *Downloader) GetRandomTargetPeer() *TargetNode
- func (d *Downloader) GetTargetPeerByID(id string) (*TargetNode, bool)
- func (d *Downloader) GetTargetPeerCount() int
- func (d *Downloader) GetTargetPeerLength() int
- func (d *Downloader) Initialize(p *Peer)
- func (d *Downloader) NewTargetNode(nodeHeaderHash *generated.NodeHeaderHash, peer *Peer)
- func (d *Downloader) RemovePeer(p *Peer) bool
- func (d *Downloader) RemovePeerFromTargetPeers(p *Peer) bool
- func (d *Downloader) RequestForBlock(blockNumber uint64) error
- type MRDataConn
- type MessageReceipt
- func (mr *MessageReceipt) Get(messageType *generated.LegacyMessage_FuncName, messageHash []byte) *generated.LegacyMessage
- func (mr *MessageReceipt) GetHashMsg(msgHash string) (value *generated.Message, ok bool)
- func (mr *MessageReceipt) GetRequestedHash(msgHash string) (value *MessageRequest, ok bool)
- func (mr *MessageReceipt) IsRequested(msgHashBytes []byte, peer *Peer, block *block.Block) bool
- func (mr *MessageReceipt) Register(msgHash string, msg *generated.Message)
- func (mr *MessageReceipt) RemoveRequestedHash(msgHash string)
- type MessageRequest
- type Msg
- type NodeHeaderHashAndPeer
- type NodeHeaderHashWithTimestamp
- type OrderedMap
- type OutgoingMessage
- type Peer
- func (p *Peer) Disconnect(reason DiscReason)
- func (p *Peer) GetCumulativeDifficulty() []byte
- func (p *Peer) GetNodeHeaderHashWithTimestamp() *NodeHeaderHashWithTimestamp
- func (p *Peer) HandleBlock(pbBlock *generated.Block)
- func (p *Peer) HandleChainState(nodeChainState *generated.NodeChainState)
- func (p *Peer) HandleTransaction(msg *Msg, txData *generated.Transaction) error
- func (p *Peer) ID() string
- func (p *Peer) IsPeerAhead() bool
- func (p *Peer) ReadMsg() (msg *Msg, size uint32, err error)
- func (p *Peer) Send(msg *Msg) error
- func (p *Peer) SendFetchBlock(blockNumber uint64) error
- func (p *Peer) SendNext() error
- func (p *Peer) SendPeerList()
- func (p *Peer) SendSync()
- func (p *Peer) SendVersion()
- type PeerInfo
- type PeersInfo
- type PriorityQueue
- type Server
- func (srv *Server) BlockReceived(peer *Peer, b *block.Block)
- func (srv *Server) ConnectPeer(peer string) error
- func (srv *Server) ConnectPeers()
- func (srv *Server) GetRegisterAndBroadcastChan() chan *messages.RegisterMessage
- func (srv *Server) HandleTransaction(mrDataConn *MRDataConn)
- func (srv *Server) LoadPeerList()
- func (srv *Server) RequestFullMessage(mrData *generated.MRData)
- func (srv *Server) Start(chain *chain.Chain) (err error)
- func (srv *Server) Stop()
- func (srv *Server) UpdatePeerList(pl *generated.PLData) error
- func (srv *Server) WritePeerList() error
- type TargetNode
Constants ¶
View Source
const SIZE = 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 DiscReason ¶
type DiscReason uint
const ( DiscRequested DiscReason = iota DiscNetworkError DiscProtocolError DiscUselessPeer DiscTooManyPeers DiscAlreadyConnected DiscIncompatibleVersion DiscInvalidIdentity DiscQuitting DiscUnexpectedIdentity DiscSelf DiscReadTimeout DiscSubprotocolError = 0x10 )
func (DiscReason) Error ¶
func (d DiscReason) Error() string
func (DiscReason) String ¶
func (d DiscReason) String() string
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
func CreateDownloader ¶
func CreateDownloader(c *chain.Chain) (d *Downloader)
func (*Downloader) AddPeer ¶
func (d *Downloader) AddPeer(p *Peer)
func (*Downloader) AddPeerToTargetPeers ¶
func (d *Downloader) AddPeerToTargetPeers(p *Peer)
func (*Downloader) BlockDownloader ¶
func (d *Downloader) BlockDownloader()
func (*Downloader) Consumer ¶
func (d *Downloader) Consumer()
func (*Downloader) DownloadMonitor ¶
func (d *Downloader) DownloadMonitor()
func (*Downloader) Exit ¶
func (d *Downloader) Exit()
func (*Downloader) GetRandomTargetPeer ¶
func (d *Downloader) GetRandomTargetPeer() *TargetNode
func (*Downloader) GetTargetPeerByID ¶
func (d *Downloader) GetTargetPeerByID(id string) (*TargetNode, bool)
func (*Downloader) GetTargetPeerCount ¶
func (d *Downloader) GetTargetPeerCount() int
func (*Downloader) GetTargetPeerLength ¶
func (d *Downloader) GetTargetPeerLength() int
func (*Downloader) Initialize ¶
func (d *Downloader) Initialize(p *Peer)
func (*Downloader) NewTargetNode ¶
func (d *Downloader) NewTargetNode(nodeHeaderHash *generated.NodeHeaderHash, peer *Peer)
func (*Downloader) RemovePeer ¶
func (d *Downloader) RemovePeer(p *Peer) bool
func (*Downloader) RemovePeerFromTargetPeers ¶
func (d *Downloader) RemovePeerFromTargetPeers(p *Peer) bool
func (*Downloader) RequestForBlock ¶
func (d *Downloader) RequestForBlock(blockNumber uint64) error
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(messageType *generated.LegacyMessage_FuncName, messageHash []byte) *generated.LegacyMessage
func (*MessageReceipt) GetHashMsg ¶
func (mr *MessageReceipt) GetHashMsg(msgHash string) (value *generated.Message, ok bool)
func (*MessageReceipt) GetRequestedHash ¶
func (mr *MessageReceipt) GetRequestedHash(msgHash string) (value *MessageRequest, ok bool)
func (*MessageReceipt) IsRequested ¶
func (*MessageReceipt) Register ¶
func (mr *MessageReceipt) Register(msgHash string, msg *generated.Message)
func (*MessageReceipt) RemoveRequestedHash ¶
func (mr *MessageReceipt) RemoveRequestedHash(msgHash string)
type MessageRequest ¶
type MessageRequest struct {
// contains filtered or unexported fields
}
func CreateMessageRequest ¶
func CreateMessageRequest(mrData *generated.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 NodeHeaderHashAndPeer ¶
type NodeHeaderHashAndPeer struct {
// contains filtered or unexported fields
}
type NodeHeaderHashWithTimestamp ¶
type NodeHeaderHashWithTimestamp struct {
// 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 *generated.LegacyMessage) *OutgoingMessage
func (*OutgoingMessage) IsExpired ¶
func (o *OutgoingMessage) IsExpired() bool
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
func (*Peer) Disconnect ¶
func (p *Peer) Disconnect(reason DiscReason)
func (*Peer) GetCumulativeDifficulty ¶
func (*Peer) GetNodeHeaderHashWithTimestamp ¶
func (p *Peer) GetNodeHeaderHashWithTimestamp() *NodeHeaderHashWithTimestamp
func (*Peer) HandleBlock ¶
func (*Peer) HandleChainState ¶
func (p *Peer) HandleChainState(nodeChainState *generated.NodeChainState)
func (*Peer) HandleTransaction ¶
func (p *Peer) HandleTransaction(msg *Msg, txData *generated.Transaction) error
func (*Peer) IsPeerAhead ¶
func (*Peer) SendFetchBlock ¶
func (*Peer) SendPeerList ¶
func (p *Peer) SendPeerList()
func (*Peer) SendVersion ¶
func (p *Peer) SendVersion()
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 Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ConnectPeer ¶
func (*Server) ConnectPeers ¶
func (srv *Server) ConnectPeers()
func (*Server) GetRegisterAndBroadcastChan ¶
func (srv *Server) GetRegisterAndBroadcastChan() chan *messages.RegisterMessage
func (*Server) HandleTransaction ¶
func (srv *Server) HandleTransaction(mrDataConn *MRDataConn)
func (*Server) LoadPeerList ¶
func (srv *Server) LoadPeerList()
func (*Server) RequestFullMessage ¶
func (*Server) WritePeerList ¶
type TargetNode ¶
type TargetNode struct {
// contains filtered or unexported fields
}
func (*TargetNode) AddRequestedBlockNumbers ¶
func (t *TargetNode) AddRequestedBlockNumbers(blockNumber uint64)
func (*TargetNode) IsRequestedBlockNumber ¶
func (t *TargetNode) IsRequestedBlockNumber(blockNumber uint64) bool
func (*TargetNode) RemoveRequestedBlockNumber ¶
func (t *TargetNode) RemoveRequestedBlockNumber(blockNumber uint64) bool
Source Files ¶
Click to show internal directories.
Click to hide internal directories.