Documentation ¶
Index ¶
- Constants
- type BlockManager
- type BlockProgressLogger
- type BroadcastMessage
- type MessageListener
- type NewPeerMessage
- type Peer
- func (p *Peer) Connect(conn net.Conn)
- func (p *Peer) Connected() bool
- func (p *Peer) Disconnect()
- func (p *Peer) GetLastDeclareBlock() *utils.Hash
- func (p *Peer) GetNetAddress() *network.PeerAddress
- func (p *Peer) GetPeerID() int32
- func (p *Peer) GetServiceFlag() protocol.ServiceFlag
- func (p *Peer) GetUserAgent() string
- func (p *Peer) HandlePingMessage(pingMessage *msg.PingMessage)
- func (p *Peer) HandlePongMessage(pongMessage *msg.PongMessage)
- func (p *Peer) HandleRemoteVersionMessage(versionMessage *msg.VersionMessage) error
- func (p *Peer) IsAllowedReadError(err error) bool
- func (p *Peer) IsValidBIP0111(command string) bool
- func (p *Peer) LastReceived() uint64
- func (p *Peer) LastSent() uint64
- func (p *Peer) LocalVersionMsg() (*msg.VersionMessage, error)
- func (p *Peer) QueueInventory(inventoryVector *msg.InventoryVector)
- func (p *Peer) ReadMessage() (msg.Message, []byte, error)
- func (p *Peer) SendAddrMessage(addresses []*network.PeerAddress) ([]*network.PeerAddress, error)
- func (p *Peer) SendGetBlocks(locator []*utils.Hash, stopHash *utils.Hash) error
- func (p *Peer) SendGetHeadersMessage(locator []*utils.Hash, stopHash *utils.Hash) error
- func (p *Peer) SendMessage(message msg.Message, doneChan chan<- struct{})
- func (p *Peer) SendRejectMessage(command string, code msg.RejectCode, reason string, hash *utils.Hash, ...)
- func (p *Peer) Stop()
- func (p *Peer) String() string
- func (p *Peer) UpdateBlockHeight(newHeight int32)
- func (p *Peer) UpdateDeclareBlock(blackHash *utils.Hash)
- func (p *Peer) WaitForDisconnect()
- func (p *Peer) WriteMessage(message msg.Message) error
- type PeerConfig
- type PeerManager
- func (peerManager *PeerManager) AddPeer(serverPeer *ServerPeer)
- func (peerManager *PeerManager) BanPeer(serverPeer *ServerPeer)
- func (peerManager *PeerManager) OutboundGroupCount(key string) int
- func (peerManager *PeerManager) Start()
- func (peerManager *PeerManager) Stop() error
- func (peerManager *PeerManager) WaitForShutdown()
- type PeerState
- type RelayMessage
- type ServerPeer
- func (serverPeer *ServerPeer) OnAddr(p *Peer, msg *msg.AddressMessage)
- func (serverPeer *ServerPeer) OnAlert(p *Peer, msg *msg.AlertMessage)
- func (serverPeer *ServerPeer) OnBlock(p *Peer, msg *msg.BlockMessage, buf []byte)
- func (serverPeer *ServerPeer) OnFilterAdd(p *Peer, msg *msg.FilterAddMessage)
- func (serverPeer *ServerPeer) OnFilterClear(p *Peer, msg *msg.FilterClearMessage)
- func (serverPeer *ServerPeer) OnFilterLoad(p *Peer, msg *msg.FilterLoadMessage)
- func (serverPeer *ServerPeer) OnGetAddr(p *Peer, msg *msg.GetAddressMessage)
- func (serverPeer *ServerPeer) OnGetBlocks(p *Peer, msg *msg.GetBlocksMessage)
- func (serverPeer *ServerPeer) OnGetData(p *Peer, msg *msg.GetDataMessage)
- func (serverPeer *ServerPeer) OnGetHeaders(p *Peer, msg *msg.GetHeadersMessage)
- func (serverPeer *ServerPeer) OnHeaders(p *Peer, msg *msg.HeadersMessage)
- func (serverPeer *ServerPeer) OnInv(p *Peer, msg *msg.InventoryMessage)
- func (serverPeer *ServerPeer) OnMemPool(p *Peer, msg *msg.MempoolMessage)
- func (serverPeer *ServerPeer) OnMerkleBlock(p *Peer, msg *msg.MerkleBlockMessage)
- func (serverPeer *ServerPeer) OnNotFound(p *Peer, msg *msg.NotFoundMessage)
- func (serverPeer *ServerPeer) OnPing(p *Peer, msg *msg.PingMessage)
- func (serverPeer *ServerPeer) OnPong(p *Peer, msg *msg.PongMessage)
- func (serverPeer *ServerPeer) OnRead(p *Peer, bytesRead int, message msg.Message, err error)
- func (serverPeer *ServerPeer) OnReject(p *Peer, msg msg.RejectMessage)
- func (serverPeer *ServerPeer) OnSendHeaders(p *Peer, msg *msg.SendHeadersMessage)
- func (serverPeer *ServerPeer) OnTx(p *Peer, msg *msg.TxMessage)
- func (serverPeer *ServerPeer) OnVerAck(p *Peer, msg *msg.VersionACKMessage)
- func (serverPeer *ServerPeer) OnVersion(p *Peer, versionMessage *msg.VersionMessage)
- func (serverPeer *ServerPeer) OnWrite(p *Peer, bytesWritten int, message msg.Message, err error)
- func (serverPeer *ServerPeer) RelayTxDisabled() bool
- func (serverPeer *ServerPeer) SetDisableRelayTx(disable bool)
- type StallControlCommand
- type StallControlMessage
- type UpdatePeerHeightsMessage
Constants ¶
View Source
const ( DefaultServices = protocol.SFNodeNetworkAsFullNode | protocol.SFNodeBloomFilter DefaultRequiredServices = protocol.SFNodeNetworkAsFullNode )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockManager ¶
type BlockManager struct { Chain *model.BlockChain // contains filtered or unexported fields }
func (*BlockManager) NewPeer ¶
func (blockManager *BlockManager) NewPeer(serverPeer *ServerPeer)
func (*BlockManager) Start ¶
func (blockManager *BlockManager) Start()
func (*BlockManager) Stop ¶
func (blockManager *BlockManager) Stop()
type BlockProgressLogger ¶
type BlockProgressLogger struct { LastBlockLogTime time.Time // contains filtered or unexported fields }
func (*BlockProgressLogger) LogBlockHeight ¶
func (blockLog *BlockProgressLogger) LogBlockHeight(block *model.Block)
type BroadcastMessage ¶
type BroadcastMessage struct { Message *msg.Message ExcludePeers []*ServerPeer }
type MessageListener ¶
type MessageListener struct { OnRead func(p *Peer, bytesRead int, message msg.Message, err error) OnWrite func(p *Peer, bytesWritten int, message msg.Message, err error) OnVersion func(p *Peer, versionMessage *msg.VersionMessage) OnGetAddr func(p *Peer, msg *msg.GetAddressMessage) OnAddr func(p *Peer, msg *msg.AddressMessage) OnPing func(p *Peer, msg *msg.PingMessage) OnPong func(p *Peer, msg *msg.PongMessage) OnAlert func(p *Peer, msg *msg.AlertMessage) OnMemPool func(p *Peer, msg *msg.MempoolMessage) OnTx func(p *Peer, msg *msg.TxMessage) OnBlock func(p *Peer, msg *msg.BlockMessage, buf []byte) OnInv func(p *Peer, msg *msg.InventoryMessage) OnHeaders func(p *Peer, msg *msg.HeadersMessage) OnNotFound func(p *Peer, msg *msg.NotFoundMessage) OnGetData func(p *Peer, msg *msg.GetDataMessage) OnGetBlocks func(p *Peer, msg *msg.GetBlocksMessage) OnGetHeaders func(p *Peer, msg *msg.GetHeadersMessage) OnFilterAdd func(p *Peer, msg *msg.FilterAddMessage) OnFilterClear func(p *Peer, msg *msg.FilterClearMessage) OnFilterLoad func(p *Peer, msg *msg.FilterLoadMessage) OnMerkleBlock func(p *Peer, msg *msg.MerkleBlockMessage) OnVerAck func(p *Peer, msg *msg.VersionACKMessage) OnReject func(p *Peer, msg msg.RejectMessage) OnSendHeaders func(p *Peer, msg *msg.SendHeadersMessage) }
type NewPeerMessage ¶
type NewPeerMessage struct {
// contains filtered or unexported fields
}
type Peer ¶
type Peer struct { Config *PeerConfig ID int32 Inbound bool BlockStatusMutex sync.RWMutex AddressString string PeerStatusMutex sync.RWMutex PeerAddress *network.PeerAddress ServiceFlag protocol.ServiceFlag UserAgent string PingNonce uint64 PingTime time.Time PingMicros int64 VersionKnown bool SentVerAck bool GotVerAck bool StallControl chan StallControlMessage ProtocolVersion uint32 LastBlock int32 ConnectedTime time.Time TimeOffset int64 StartingHeight int32 SendHeadersPreferred bool OutputQueue chan msg.OutMessage SendQueue chan msg.OutMessage GetBlocksLock sync.Mutex GetBlocksBegin *utils.Hash GetBlocksStop *utils.Hash GetHeadersLock sync.Mutex GetHeadersBegin *utils.Hash GetHeadersStop *utils.Hash // contains filtered or unexported fields }
func NewInboundPeer ¶
func NewInboundPeer(peerConfig *PeerConfig) *Peer
func NewOutboundPeer ¶
func NewOutboundPeer(peerConfig *PeerConfig, addressString string) (*Peer, error)
func (*Peer) Disconnect ¶
func (p *Peer) Disconnect()
func (*Peer) GetLastDeclareBlock ¶
func (*Peer) GetNetAddress ¶
func (p *Peer) GetNetAddress() *network.PeerAddress
func (*Peer) GetServiceFlag ¶
func (p *Peer) GetServiceFlag() protocol.ServiceFlag
func (*Peer) GetUserAgent ¶
func (*Peer) HandlePingMessage ¶
func (p *Peer) HandlePingMessage(pingMessage *msg.PingMessage)
func (*Peer) HandlePongMessage ¶
func (p *Peer) HandlePongMessage(pongMessage *msg.PongMessage)
func (*Peer) HandleRemoteVersionMessage ¶
func (p *Peer) HandleRemoteVersionMessage(versionMessage *msg.VersionMessage) error
func (*Peer) IsAllowedReadError ¶
func (*Peer) IsValidBIP0111 ¶
func (*Peer) LastReceived ¶
func (*Peer) LocalVersionMsg ¶
func (p *Peer) LocalVersionMsg() (*msg.VersionMessage, error)
func (*Peer) QueueInventory ¶
func (p *Peer) QueueInventory(inventoryVector *msg.InventoryVector)
func (*Peer) SendAddrMessage ¶
func (p *Peer) SendAddrMessage(addresses []*network.PeerAddress) ([]*network.PeerAddress, error)
func (*Peer) SendGetBlocks ¶
func (*Peer) SendGetHeadersMessage ¶
func (*Peer) SendMessage ¶
func (*Peer) SendRejectMessage ¶
func (*Peer) UpdateBlockHeight ¶
func (*Peer) UpdateDeclareBlock ¶
func (*Peer) WaitForDisconnect ¶
func (p *Peer) WaitForDisconnect()
type PeerConfig ¶
type PeerConfig struct { NewBlock utils.HashFunc HostToAddressFunc network.HostToNetAddrFunc BestAddress network.PeerAddressFunc Proxy string UserAgent string UserAgentVersion string // BIP 14 UserAgentComments []string ServicesFlag protocol.ServiceFlag ProtocolVersion uint32 DisableRelayTx bool Listener MessageListener ChainParams *msg.BitcoinParams }
type PeerManager ¶
type PeerManager struct { BlockManager *BlockManager // contains filtered or unexported fields }
func NewPeerManager ¶
func NewPeerManager(listenAddrs []string, storage storage.Storage, bitcoinParam *msg.BitcoinParams) (*PeerManager, error)
func (*PeerManager) AddPeer ¶
func (peerManager *PeerManager) AddPeer(serverPeer *ServerPeer)
func (*PeerManager) BanPeer ¶
func (peerManager *PeerManager) BanPeer(serverPeer *ServerPeer)
func (*PeerManager) OutboundGroupCount ¶
func (peerManager *PeerManager) OutboundGroupCount(key string) int
func (*PeerManager) Start ¶
func (peerManager *PeerManager) Start()
func (*PeerManager) Stop ¶
func (peerManager *PeerManager) Stop() error
func (*PeerManager) WaitForShutdown ¶
func (peerManager *PeerManager) WaitForShutdown()
type RelayMessage ¶
type RelayMessage struct { InventoryVector *msg.InventoryVector Data interface{} }
type ServerPeer ¶
type ServerPeer struct { *Peer // contains filtered or unexported fields }
func NewServerPeer ¶
func NewServerPeer(peerManager *PeerManager, isPersistent bool) *ServerPeer
func (*ServerPeer) OnAddr ¶
func (serverPeer *ServerPeer) OnAddr(p *Peer, msg *msg.AddressMessage)
func (*ServerPeer) OnAlert ¶
func (serverPeer *ServerPeer) OnAlert(p *Peer, msg *msg.AlertMessage)
func (*ServerPeer) OnBlock ¶
func (serverPeer *ServerPeer) OnBlock(p *Peer, msg *msg.BlockMessage, buf []byte)
func (*ServerPeer) OnFilterAdd ¶
func (serverPeer *ServerPeer) OnFilterAdd(p *Peer, msg *msg.FilterAddMessage)
func (*ServerPeer) OnFilterClear ¶
func (serverPeer *ServerPeer) OnFilterClear(p *Peer, msg *msg.FilterClearMessage)
func (*ServerPeer) OnFilterLoad ¶
func (serverPeer *ServerPeer) OnFilterLoad(p *Peer, msg *msg.FilterLoadMessage)
func (*ServerPeer) OnGetAddr ¶
func (serverPeer *ServerPeer) OnGetAddr(p *Peer, msg *msg.GetAddressMessage)
func (*ServerPeer) OnGetBlocks ¶
func (serverPeer *ServerPeer) OnGetBlocks(p *Peer, msg *msg.GetBlocksMessage)
func (*ServerPeer) OnGetData ¶
func (serverPeer *ServerPeer) OnGetData(p *Peer, msg *msg.GetDataMessage)
func (*ServerPeer) OnGetHeaders ¶
func (serverPeer *ServerPeer) OnGetHeaders(p *Peer, msg *msg.GetHeadersMessage)
func (*ServerPeer) OnHeaders ¶
func (serverPeer *ServerPeer) OnHeaders(p *Peer, msg *msg.HeadersMessage)
func (*ServerPeer) OnInv ¶
func (serverPeer *ServerPeer) OnInv(p *Peer, msg *msg.InventoryMessage)
func (*ServerPeer) OnMemPool ¶
func (serverPeer *ServerPeer) OnMemPool(p *Peer, msg *msg.MempoolMessage)
func (*ServerPeer) OnMerkleBlock ¶
func (serverPeer *ServerPeer) OnMerkleBlock(p *Peer, msg *msg.MerkleBlockMessage)
func (*ServerPeer) OnNotFound ¶
func (serverPeer *ServerPeer) OnNotFound(p *Peer, msg *msg.NotFoundMessage)
func (*ServerPeer) OnPing ¶
func (serverPeer *ServerPeer) OnPing(p *Peer, msg *msg.PingMessage)
func (*ServerPeer) OnPong ¶
func (serverPeer *ServerPeer) OnPong(p *Peer, msg *msg.PongMessage)
func (*ServerPeer) OnReject ¶
func (serverPeer *ServerPeer) OnReject(p *Peer, msg msg.RejectMessage)
func (*ServerPeer) OnSendHeaders ¶
func (serverPeer *ServerPeer) OnSendHeaders(p *Peer, msg *msg.SendHeadersMessage)
func (*ServerPeer) OnVerAck ¶
func (serverPeer *ServerPeer) OnVerAck(p *Peer, msg *msg.VersionACKMessage)
func (*ServerPeer) OnVersion ¶
func (serverPeer *ServerPeer) OnVersion(p *Peer, versionMessage *msg.VersionMessage)
func (*ServerPeer) RelayTxDisabled ¶
func (serverPeer *ServerPeer) RelayTxDisabled() bool
func (*ServerPeer) SetDisableRelayTx ¶
func (serverPeer *ServerPeer) SetDisableRelayTx(disable bool)
type StallControlCommand ¶
type StallControlCommand uint8
const ( SccSendMessage StallControlCommand = iota SccReceiveMessage SccHandlerStart SccHandlerDone )
type StallControlMessage ¶
type StallControlMessage struct { Command StallControlCommand Message msg.Message }
type UpdatePeerHeightsMessage ¶
type UpdatePeerHeightsMessage struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.