Documentation ¶
Index ¶
- Constants
- func ProcessForRPC(message interface{}) (rsp interface{}, err error)
- func SetMsgHandle(ctx context.Context, msgChan <-chan *peer.PeerMessage, server *Server)
- type BannedInfo
- type MsgHandle
- type PingMsg
- type RPCConnManager
- func (cm *RPCConnManager) AddRebroadcastInventory(iv *wire.InvVect, data interface{})
- func (cm *RPCConnManager) BroadcastMessage(msg wire.Message)
- func (cm *RPCConnManager) ClearBanned()
- func (cm *RPCConnManager) Connect(addr string, permanent bool) error
- func (cm *RPCConnManager) ConnectedCount() int32
- func (cm *RPCConnManager) ConnectedPeers() []RPCServerPeer
- func (cm *RPCConnManager) DisconnectByAddr(addr string) error
- func (cm *RPCConnManager) DisconnectByID(id int32) error
- func (cm *RPCConnManager) ListBanned() (*btcjson.ListBannedResult, *btcjson.RPCError)
- func (cm *RPCConnManager) NetTotals() (uint64, uint64)
- func (cm *RPCConnManager) PersistentPeers() []RPCServerPeer
- func (cm *RPCConnManager) RemoveByAddr(addr string) error
- func (cm *RPCConnManager) RemoveByID(id int32) error
- func (cm *RPCConnManager) SetBan(c *btcjson.SetBanCmd) *btcjson.RPCError
- type RPCServerPeer
- type Server
- func (s *Server) AddBanScore(peerAddr string, persistent uint32, transient uint32, reason string)
- func (s *Server) AddBytesReceived(bytesReceived uint64)
- func (s *Server) AddBytesSent(bytesSent uint64)
- func (s *Server) AddPeer(sp *serverPeer)
- func (s *Server) AddRebroadcastInventory(iv *wire.InvVect, data interface{})
- func (s *Server) AnnounceNewTransactions(txns []*mempool.TxEntry)
- func (s *Server) BanAddr(addr string, startTime int64, endTime int64, reason int) bool
- func (s *Server) BanPeer(sp *serverPeer)
- func (s *Server) BroadcastMessage(msg wire.Message, exclPeers ...*serverPeer)
- func (s *Server) ClearBanned()
- func (s *Server) ConnectedCount() int32
- func (s *Server) GetBannedInfo() []*BannedInfo
- func (s *Server) HandleMinedBlock(pblock *block.Block, done chan error)
- func (s *Server) NetTotals() (uint64, uint64)
- func (s *Server) OutboundGroupCount(key string) int
- func (s *Server) RelayBlocks(invVects []*wire.InvVect, headers []*block.BlockHeader)
- func (s *Server) RelayInventory(invVect *wire.InvVect, data interface{})
- func (s *Server) RelayUpdatedTipBlocks(event *chain.TipUpdatedEvent)
- func (s *Server) RemoveRebroadcastInventory(iv *wire.InvVect)
- func (s *Server) ScheduleShutdown(duration time.Duration)
- func (s *Server) Start()
- func (s *Server) Stop() error
- func (s *Server) TransactionConfirmed(tx *tx.Tx)
- func (s *Server) UnbanAddr(addr string) bool
- func (s *Server) UpdatePeerHeights(latestBlkHash *util.Hash, latestHeight int32, updateSource *peer.Peer)
- func (s *Server) WaitForShutdown()
- type TxRelayer
Constants ¶
const ( BanReasonNodeMisbehaving int = 1 BanReasonManuallyAdded int = 2 // REVERT_TO_INV_DIFF when peer is neer to tip, set its revertToInv to false back REVERT_TO_INV_DIFF = 7 )
Variables ¶
This section is empty.
Functions ¶
func ProcessForRPC ¶
func ProcessForRPC(message interface{}) (rsp interface{}, err error)
ProcessForRPC are RPC process things
func SetMsgHandle ¶
func SetMsgHandle(ctx context.Context, msgChan <-chan *peer.PeerMessage, server *Server)
SetMsgHandle create a msgHandle for these message from peer And RPC. Then begins the core block handler which processes block and inv messages.
Types ¶
type BannedInfo ¶ added in v0.0.4
type RPCConnManager ¶
type RPCConnManager struct {
// contains filtered or unexported fields
}
RPCConnManager provides a connection manager for use with the RPC server and implements the rpcserverConnManager interface.
func NewRPCConnManager ¶
func NewRPCConnManager(s *Server) *RPCConnManager
func (*RPCConnManager) AddRebroadcastInventory ¶
func (cm *RPCConnManager) AddRebroadcastInventory(iv *wire.InvVect, data interface{})
AddRebroadcastInventory adds the provided inventory to the list of inventories to be rebroadcast at random intervals until they show up in a block.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
func (*RPCConnManager) BroadcastMessage ¶
func (cm *RPCConnManager) BroadcastMessage(msg wire.Message)
BroadcastMessage sends the provided message to all currently connected peers.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
func (*RPCConnManager) ClearBanned ¶ added in v0.0.4
func (cm *RPCConnManager) ClearBanned()
func (*RPCConnManager) Connect ¶
func (cm *RPCConnManager) Connect(addr string, permanent bool) error
Connect adds the provided address as a new outbound peer. The permanent flag indicates whether or not to make the peer persistent and reconnect if the connection is lost. Attempting to connect to an already existing peer will return an error.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
func (*RPCConnManager) ConnectedCount ¶
func (cm *RPCConnManager) ConnectedCount() int32
ConnectedCount returns the number of currently connected peers.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
func (*RPCConnManager) ConnectedPeers ¶
func (cm *RPCConnManager) ConnectedPeers() []RPCServerPeer
ConnectedPeers returns an array consisting of all connected peers.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
func (*RPCConnManager) DisconnectByAddr ¶
func (cm *RPCConnManager) DisconnectByAddr(addr string) error
DisconnectByAddr disconnects the peer associated with the provided address. This applies to both inbound and outbound peers. Attempting to remove an address that does not exist will return an error.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
func (*RPCConnManager) DisconnectByID ¶
func (cm *RPCConnManager) DisconnectByID(id int32) error
DisconnectByID disconnects the peer associated with the provided id. This applies to both inbound and outbound peers. Attempting to remove an id that does not exist will return an error.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
func (*RPCConnManager) ListBanned ¶ added in v0.0.4
func (cm *RPCConnManager) ListBanned() (*btcjson.ListBannedResult, *btcjson.RPCError)
func (*RPCConnManager) NetTotals ¶
func (cm *RPCConnManager) NetTotals() (uint64, uint64)
NetTotals returns the sum of all bytes received and sent across the network for all peers.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
func (*RPCConnManager) PersistentPeers ¶
func (cm *RPCConnManager) PersistentPeers() []RPCServerPeer
PersistentPeers returns an array consisting of all the added persistent peers.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
func (*RPCConnManager) RemoveByAddr ¶
func (cm *RPCConnManager) RemoveByAddr(addr string) error
RemoveByAddr removes the peer associated with the provided address from the list of persistent peers. Attempting to remove an address that does not exist will return an error.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
func (*RPCConnManager) RemoveByID ¶
func (cm *RPCConnManager) RemoveByID(id int32) error
RemoveByID removes the peer associated with the provided id from the list of persistent peers. Attempting to remove an id that does not exist will return an error.
This function is safe for concurrent access and is part of the rpcserverConnManager interface implementation.
type RPCServerPeer ¶
type RPCServerPeer interface { // ToPeer returns the underlying peer instance. ToPeer() *peer.Peer // IsTxRelayDisabled returns whether or not the peer has disabled // transaction relay. IsTxRelayDisabled() bool // BanScore returns the current integer value that represents how close // the peer is to being banned. BanScore() uint32 // FeeFilter returns the requested current minimum fee rate for which // transactions should be announced. FeeFilter() int64 }
RPCServerPeer represents a peer for use with the RPC server.
The interface contract requires that all of these methods are safe for concurrent access.
type Server ¶
type Server struct { MsgChan chan *peer.PeerMessage // contains filtered or unexported fields }
Server provides a bitcoin server for handling communications to and from bitcoin peers.
func NewServer ¶
func NewServer(chainParams *model.BitcoinParams, ts *util.MedianTime, interrupt <-chan struct{}) (*Server, error)
func (*Server) AddBanScore ¶ added in v0.0.4
func (*Server) AddBytesReceived ¶
AddBytesReceived adds the passed number of bytes to the total bytes received counter for the server. It is safe for concurrent access.
func (*Server) AddBytesSent ¶
AddBytesSent adds the passed number of bytes to the total bytes sent counter for the server. It is safe for concurrent access.
func (*Server) AddPeer ¶
func (s *Server) AddPeer(sp *serverPeer)
AddPeer adds a new peer that has already been connected to the server.
func (*Server) AddRebroadcastInventory ¶
AddRebroadcastInventory adds 'iv' to the list of inventories to be rebroadcasted at random intervals until they show up in a block.
func (*Server) AnnounceNewTransactions ¶
AnnounceNewTransactions generates and relays inventory vectors and notifies both websocket and getblocktemplate long poll clients of the passed transactions. This function should be called whenever new transactions are added to the mempool.
func (*Server) BanPeer ¶
func (s *Server) BanPeer(sp *serverPeer)
BanPeer bans a peer that has already been connected to the server by ip.
func (*Server) BroadcastMessage ¶
BroadcastMessage sends msg to all peers currently connected to the server except those in the passed peers to exclude.
func (*Server) ClearBanned ¶ added in v0.0.4
func (s *Server) ClearBanned()
func (*Server) ConnectedCount ¶
ConnectedCount returns the number of currently connected peers.
func (*Server) GetBannedInfo ¶ added in v0.0.4
func (s *Server) GetBannedInfo() []*BannedInfo
func (*Server) HandleMinedBlock ¶ added in v0.0.3
func (*Server) NetTotals ¶
NetTotals returns the sum of all bytes received and sent across the network for all peers. It is safe for concurrent access.
func (*Server) OutboundGroupCount ¶
OutboundGroupCount returns the number of peers connected to the given outbound group key.
func (*Server) RelayBlocks ¶ added in v0.0.7
func (s *Server) RelayBlocks(invVects []*wire.InvVect, headers []*block.BlockHeader)
func (*Server) RelayInventory ¶
RelayInventory relays the passed inventory vector to all connected peers that are not already known to have it.
func (*Server) RelayUpdatedTipBlocks ¶
func (s *Server) RelayUpdatedTipBlocks(event *chain.TipUpdatedEvent)
RelayUpdatedTipBlocks relays blocks leads to new main chain
func (*Server) RemoveRebroadcastInventory ¶
RemoveRebroadcastInventory removes 'iv' from the list of items to be rebroadcasted if present.
func (*Server) ScheduleShutdown ¶
ScheduleShutdown schedules a server shutdown after the specified duration. It also dynamically adjusts how often to warn the server is going down based on remaining duration.
func (*Server) Stop ¶
Stop gracefully shuts down the server by stopping and disconnecting all peers and the main listener.
func (*Server) TransactionConfirmed ¶
TransactionConfirmed marks a Transaction as no longer needing rebroadcasting when it has one confirmation on the main chain.
func (*Server) UpdatePeerHeights ¶
func (s *Server) UpdatePeerHeights(latestBlkHash *util.Hash, latestHeight int32, updateSource *peer.Peer)
UpdatePeerHeights updates the heights of all peers who have have announced the latest connected main chain block, or a recognized orphan. These height updates allow us to dynamically refresh peer heights, ensuring sync peer selection has access to the latest block heights for each peer.
func (*Server) WaitForShutdown ¶
func (s *Server) WaitForShutdown()
WaitForShutdown blocks until the main listener and peer handlers are stopped.
type TxRelayer ¶ added in v0.0.7
type TxRelayer struct {
// contains filtered or unexported fields
}
func NewTxRelayer ¶ added in v0.0.7
func NewTxRelayer() *TxRelayer