Documentation ¶
Index ¶
- type Client
- func (s *Client) AddBytesReceived(bytesReceived uint64)
- func (s *Client) AddBytesSent(bytesSent uint64)
- func (s *Client) AddPeer(sp *serverPeer)
- func (s *Client) AddServiceNode(node *sn.ServiceNode)
- func (s *Client) BanPeer(sp *serverPeer)
- func (s *Client) BroadcastMessage(msg wire.Message, exclPeers ...*serverPeer)
- func (s *Client) CallService(service string, params []interface{}, query int) (*SnodeReply, string, error)
- func (s *Client) CallServiceRaw(service string, params []interface{}, query int) (string, []SnodeReply, error)
- func (s *Client) ConnectedCount() int32
- func (s *Client) DecodeTransaction(service string, txhex interface{}, query int) (*SnodeReply, string, error)
- func (s *Client) DecodeTransactionRaw(service string, txhex interface{}, query int) (string, []SnodeReply, error)
- func (s *Client) GetBlock(service string, block interface{}, query int) (*SnodeReply, string, error)
- func (s *Client) GetBlockCount(service string, query int) (*SnodeReply, string, error)
- func (s *Client) GetBlockCountRaw(service string, query int) (string, []SnodeReply, error)
- func (s *Client) GetBlockHash(service string, block interface{}, query int) (*SnodeReply, string, error)
- func (s *Client) GetBlockHashRaw(service string, block interface{}, query int) (string, []SnodeReply, error)
- func (s *Client) GetBlockRaw(service string, block interface{}, query int) (string, []SnodeReply, error)
- func (s *Client) GetBlocks(service string, blocks []interface{}, query int) (*SnodeReply, string, error)
- func (s *Client) GetBlocksRaw(service string, blocks []interface{}, query int) (string, []SnodeReply, error)
- func (s *Client) GetTransaction(service string, block interface{}, query int) (*SnodeReply, string, error)
- func (s *Client) GetTransactionRaw(service string, txid interface{}, query int) (string, []SnodeReply, error)
- func (s *Client) GetTransactions(service string, txids []interface{}, query int) (*SnodeReply, string, error)
- func (s *Client) GetTransactionsRaw(service string, txids []interface{}, query int) (string, []SnodeReply, error)
- func (s *Client) HasNetworkService(service string) bool
- func (s *Client) HasSPVService(service string) bool
- func (s *Client) ListNetworkServices() []string
- func (s *Client) NetTotals() (uint64, uint64)
- func (s *Client) OutboundGroupCount(key string) int
- func (s *Client) ScheduleShutdown(duration time.Duration)
- func (s *Client) SendTransaction(service string, txhex interface{}, query int) (*SnodeReply, string, error)
- func (s *Client) SendTransactionRaw(service string, txhex interface{}, query int) (string, []SnodeReply, error)
- func (s *Client) Start()
- func (s *Client) Stop() error
- func (s *Client) WaitForServices(ctx context.Context, services []string, query int) error
- func (s *Client) WaitForShutdown()
- func (s *Client) WaitForXRouter(ctx context.Context) (bool, error)
- type Config
- type FetchDataError
- type SnodeReply
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AddBytesReceived ¶
AddBytesReceived adds the passed number of bytes to the total bytes received counter for the server. It is safe for concurrent access.
func (*Client) AddBytesSent ¶
AddBytesSent adds the passed number of bytes to the total bytes sent counter for the server. It is safe for concurrent access.
func (*Client) AddPeer ¶
func (s *Client) AddPeer(sp *serverPeer)
AddPeer adds a new peer that has already been connected to the server.
func (*Client) AddServiceNode ¶
func (s *Client) AddServiceNode(node *sn.ServiceNode)
AddServiceNode adds the specified service node to the client's list. Only EXR snodes are added. Any services that do not support Enterprise XRouter are not added.
func (*Client) BanPeer ¶
func (s *Client) BanPeer(sp *serverPeer)
BanPeer bans a peer that has already been connected to the server by ip.
func (*Client) BroadcastMessage ¶
BroadcastMessage sends msg to all peers currently connected to the server except those in the passed peers to exclude.
func (*Client) CallService ¶
func (s *Client) CallService(service string, params []interface{}, query int) (*SnodeReply, string, error)
CallService submits requests to [query] number of endpoints. The most common reply is returned.
func (*Client) CallServiceRaw ¶
func (s *Client) CallServiceRaw(service string, params []interface{}, query int) (string, []SnodeReply, error)
CallServiceRaw submits requests to [query] number of endpoints. All replies are returned.
func (*Client) ConnectedCount ¶
ConnectedCount returns the number of currently connected peers.
func (*Client) DecodeTransaction ¶
func (s *Client) DecodeTransaction(service string, txhex interface{}, query int) (*SnodeReply, string, error)
DecodeTransaction fetches the transaction data by hash or transaction id. Returns the most common reply.
func (*Client) DecodeTransactionRaw ¶
func (s *Client) DecodeTransactionRaw(service string, txhex interface{}, query int) (string, []SnodeReply, error)
DecodeTransactionRaw fetches the transaction data by hash or transaction id. Returns all replies.
func (*Client) GetBlock ¶
func (s *Client) GetBlock(service string, block interface{}, query int) (*SnodeReply, string, error)
GetBlock fetches the block data by block hash or block height. Returns the most common reply.
func (*Client) GetBlockCount ¶
GetBlockCount SPV call fetches the block count (chain height) of the specified token. Returns the most common reply.
func (*Client) GetBlockCountRaw ¶
GetBlockCountRaw SPV call fetches the block count (chain height) of the specified token. Returns all replies.
func (*Client) GetBlockHash ¶
func (s *Client) GetBlockHash(service string, block interface{}, query int) (*SnodeReply, string, error)
GetBlockHash SPV call fetches the block hash with the specified block number. Returns the most common reply.
func (*Client) GetBlockHashRaw ¶
func (s *Client) GetBlockHashRaw(service string, block interface{}, query int) (string, []SnodeReply, error)
GetBlockHashRaw SPV call fetches the block hash with the specified block number. Returns all replies.
func (*Client) GetBlockRaw ¶
func (s *Client) GetBlockRaw(service string, block interface{}, query int) (string, []SnodeReply, error)
GetBlockRaw fetches the block data by block hash or block height. Returns all replies.
func (*Client) GetBlocks ¶
func (s *Client) GetBlocks(service string, blocks []interface{}, query int) (*SnodeReply, string, error)
GetBlocks fetches the blocks by block hash or block height. Returns the most common reply.
func (*Client) GetBlocksRaw ¶
func (s *Client) GetBlocksRaw(service string, blocks []interface{}, query int) (string, []SnodeReply, error)
GetBlocks fetches the blocks by block hash or block height. Returns all replies.
func (*Client) GetTransaction ¶
func (s *Client) GetTransaction(service string, block interface{}, query int) (*SnodeReply, string, error)
GetTransaction fetches the transaction by hash or transaction id. Returns the most common reply.
func (*Client) GetTransactionRaw ¶
func (s *Client) GetTransactionRaw(service string, txid interface{}, query int) (string, []SnodeReply, error)
GetTransactionRaw fetches the transaction by hash or transaction id. Returns all replies.
func (*Client) GetTransactions ¶
func (s *Client) GetTransactions(service string, txids []interface{}, query int) (*SnodeReply, string, error)
GetTransactions fetches the transactions by hash or transaction id. Returns the most common reply.
func (*Client) GetTransactionsRaw ¶
func (s *Client) GetTransactionsRaw(service string, txids []interface{}, query int) (string, []SnodeReply, error)
GetTransactionsRaw fetches the transactions by hash or transaction id. Returns all replies.
func (*Client) HasNetworkService ¶
HasNetworkService returns true if the network service was found. If no namespace is specified the SPV namespace will be searched followed by the xrs namespace.
func (*Client) HasSPVService ¶
HasSPVService returns true if the SPV network service was found for the specified token.
func (*Client) ListNetworkServices ¶
ListNetworkServices lists all known SPV and XCloud network services (xr and xrs).
func (*Client) NetTotals ¶
NetTotals returns the sum of all bytes received and sent across the network for all peers. It is safe for concurrent access.
func (*Client) OutboundGroupCount ¶
OutboundGroupCount returns the number of peers connected to the given outbound group key.
func (*Client) 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 (*Client) SendTransaction ¶
func (s *Client) SendTransaction(service string, txhex interface{}, query int) (*SnodeReply, string, error)
SendTransaction submits a transaction to the network of the specified token. Returns the most common reply.
func (*Client) SendTransactionRaw ¶
func (s *Client) SendTransactionRaw(service string, txhex interface{}, query int) (string, []SnodeReply, error)
SendTransactionRaw submits a transaction to the network of the specified token. Returns all replies.
func (*Client) Stop ¶
Stop gracefully shuts down the server by stopping and disconnecting all peers and the main listener.
func (*Client) WaitForServices ¶
WaitForServices will block until the specified services become available or the context timeout occurs. This is useful to prevent code from executing until the network service is found. By default this method will check for the existence of a service every 100 milliseconds.
func (*Client) WaitForShutdown ¶
func (s *Client) WaitForShutdown()
WaitForShutdown blocks until the main listener and peer handlers are stopped.
type FetchDataError ¶
fetchDataFromSnodes queries N number of service nodes and returns the results.
type SnodeReply ¶
func MostCommonReply ¶
func MostCommonReply(replies []SnodeReply, query int, service, requestName string) (*SnodeReply, string, error)
MostCommonReply returns the most common reply from the reply list