xrouter

package
v0.8.3-0...-0a3fdd4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: ISC Imports: 26 Imported by: 0

Documentation

Index

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 NewClient

func NewClient(params chaincfg.Params) (*Client, error)

NewClient creates and returns a new XRouter client.

func (*Client) AddBytesReceived

func (s *Client) AddBytesReceived(bytesReceived uint64)

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

func (s *Client) AddBytesSent(bytesSent uint64)

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

func (s *Client) BroadcastMessage(msg wire.Message, exclPeers ...*serverPeer)

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

func (s *Client) ConnectedCount() int32

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

func (s *Client) GetBlockCount(service string, query int) (*SnodeReply, string, error)

GetBlockCount SPV call fetches the block count (chain height) of the specified token. Returns the most common reply.

func (*Client) GetBlockCountRaw

func (s *Client) GetBlockCountRaw(service string, query int) (string, []SnodeReply, error)

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

func (s *Client) HasNetworkService(service string) bool

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

func (s *Client) HasSPVService(service string) bool

HasSPVService returns true if the SPV network service was found for the specified token.

func (*Client) ListNetworkServices

func (s *Client) ListNetworkServices() []string

ListNetworkServices lists all known SPV and XCloud network services (xr and xrs).

func (*Client) NetTotals

func (s *Client) NetTotals() (uint64, uint64)

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

func (s *Client) OutboundGroupCount(key string) int

OutboundGroupCount returns the number of peers connected to the given outbound group key.

func (*Client) ScheduleShutdown

func (s *Client) ScheduleShutdown(duration time.Duration)

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) Start

func (s *Client) Start()

Start begins accepting connections from peers.

func (*Client) Stop

func (s *Client) Stop() error

Stop gracefully shuts down the server by stopping and disconnecting all peers and the main listener.

func (*Client) WaitForServices

func (s *Client) WaitForServices(ctx context.Context, services []string, query int) error

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.

func (*Client) WaitForXRouter

func (s *Client) WaitForXRouter(ctx context.Context) (bool, error)

type Config

type Config struct {
	MaxPeers       int
	SimNet         bool
	DisableBanning bool
	BanThreshold   uint32
	BanDuration    time.Duration
	DataDir        string
	AddPeers       []string
	ConnectPeers   []string
	// contains filtered or unexported fields
}

type FetchDataError

type FetchDataError struct {
	Error string `json:"error"`
	Code  int    `json:"code"`
}

fetchDataFromSnodes queries N number of service nodes and returns the results.

type SnodeReply

type SnodeReply struct {
	Pubkey []byte
	Hash   []byte
	Reply  []byte
}

func MostCommonReply

func MostCommonReply(replies []SnodeReply, query int, service, requestName string) (*SnodeReply, string, error)

MostCommonReply returns the most common reply from the reply list

Jump to

Keyboard shortcuts

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