Documentation ¶
Overview ¶
This is the network client for communication with nodes It is used by nodes to communicate with other nodes and by lite wallets to communicate with nodes
Index ¶
- type ComBlock
- type ComGetBlocks
- type ComGetData
- type ComGetFirstBlocksData
- type ComGetHistoryTransactions
- type ComGetNodeState
- type ComGetUnspentTransactions
- type ComGetWalletBalance
- type ComHistoryTransaction
- type ComInv
- type ComManageNode
- type ComNewTransaction
- type ComNewTransactionData
- type ComRequestTransaction
- type ComRequestTransactionData
- type ComTx
- type ComUnspentTransaction
- type ComUnspentTransactions
- type ComVersion
- type ComWalletBalance
- type NodeClient
- func (c *NodeClient) BuildCommandData(command string, data interface{}) ([]byte, error)
- func (c *NodeClient) BuildCommandDataWithAuth(command string, data interface{}) ([]byte, error)
- func (c *NodeClient) CheckNodeAddress(address netlib.NodeAddr) error
- func (c *NodeClient) SendAddNode(node netlib.NodeAddr) error
- func (c *NodeClient) SendAddrList(address netlib.NodeAddr, addresses []netlib.NodeAddr) error
- func (c *NodeClient) SendBlock(addr netlib.NodeAddr, BlockSerialised []byte) error
- func (c *NodeClient) SendData(addr netlib.NodeAddr, data []byte) error
- func (c *NodeClient) SendDataWaitResponse(addr netlib.NodeAddr, data []byte, datapayload interface{}) error
- func (c *NodeClient) SendGetBalance(addr netlib.NodeAddr, address string) (ComWalletBalance, error)
- func (c *NodeClient) SendGetBlocks(address netlib.NodeAddr, startfrom []byte) error
- func (c *NodeClient) SendGetBlocksUpper(address netlib.NodeAddr, startfrom []byte) error
- func (c *NodeClient) SendGetData(address netlib.NodeAddr, kind string, id []byte) error
- func (c *NodeClient) SendGetFirstBlocks(address netlib.NodeAddr) (*ComGetFirstBlocksData, error)
- func (c *NodeClient) SendGetHistory(addr netlib.NodeAddr, address string) ([]ComHistoryTransaction, error)
- func (c *NodeClient) SendGetNodes() ([]netlib.NodeAddr, error)
- func (c *NodeClient) SendGetState() (ComGetNodeState, error)
- func (c *NodeClient) SendGetUnspent(addr netlib.NodeAddr, address string, chaintip []byte) (ComUnspentTransactions, error)
- func (c *NodeClient) SendInv(address netlib.NodeAddr, kind string, items [][]byte) error
- func (c *NodeClient) SendNewTransaction(addr netlib.NodeAddr, from string, tx []byte) ([]byte, error)
- func (c *NodeClient) SendNewTransactionData(addr netlib.NodeAddr, from string, txBytes []byte, signatures [][]byte) ([]byte, error)
- func (c *NodeClient) SendRemoveNode(node netlib.NodeAddr) error
- func (c *NodeClient) SendRequestNewTransaction(addr netlib.NodeAddr, PubKey []byte, to string, amount float64) ([]byte, [][]byte, error)
- func (c *NodeClient) SendTx(addr netlib.NodeAddr, tnxserialised []byte) error
- func (c *NodeClient) SendVersion(addr netlib.NodeAddr, bestHeight int) error
- func (c *NodeClient) SendVoid(address netlib.NodeAddr) error
- func (c *NodeClient) SetAuthStr(auth string)
- func (c *NodeClient) SetNodeAddress(address netlib.NodeAddr)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComGetBlocks ¶
type ComGetBlocks struct { AddrFrom netlib.NodeAddr StartFrom []byte // has of block from which to start and go down or go up in case of Up command }
this struct can be used for 2 commands. to get blocks starting from some block to down or to up
type ComGetFirstBlocksData ¶
type ComGetFirstBlocksData struct { Blocks [][]byte // lowest block first // it is serialised BlockShort structure Height int }
Response of GetBlock request
type ComGetHistoryTransactions ¶
type ComGetHistoryTransactions struct {
Address string
}
Request for history of transactions
type ComGetNodeState ¶
type ComGetNodeState struct { Host string BlocksNumber int ExpectingBlocksHeight int TransactionsCached int UnspentOutputs int }
To get node state
type ComGetUnspentTransactions ¶
For request to get list of unspent transactions by wallet
type ComGetWalletBalance ¶
type ComGetWalletBalance struct {
Address string
}
Request for a wallet balance
type ComHistoryTransaction ¶
type ComHistoryTransaction struct { IOType bool // In (false) or Out (true) TXID []byte Amount float64 From string To string }
Record of transaction in list of history transactions
type ComManageNode ¶
To send nodes manage command.
type ComNewTransaction ¶
New Transaction command. Is used by lite wallets
type ComNewTransactionData ¶
New Transaction Data command. It includes prepared TX and signatures for imputs
type ComRequestTransaction ¶
type ComRequestTransaction struct { PubKey []byte To string Amount float64 Signature []byte // to confirm request is from owner of PubKey (TODO) }
To Request new transaction by wallet. Wallet sends address where to send and amount to send and own pubkey. Server returns transaction but wihout signatures
type ComRequestTransactionData ¶
Response on prepare transaction request. Returns transaction without signs and data to sign
type ComUnspentTransaction ¶
Unspent Transaction record
type ComUnspentTransactions ¶
type ComUnspentTransactions struct { Transactions []ComUnspentTransaction LastBlock []byte }
Lit of unspent transactions returned on request
type ComVersion ¶
Version mesage to other nodes
type ComWalletBalance ¶
Wallet Balance response
type NodeClient ¶
type NodeClient struct { DataDir string NodeAddress netlib.NodeAddr Address string // wallet address Logger *utils.LoggerMan NodeNet *netlib.NodeNetwork NodeAuthStr string }
func (*NodeClient) BuildCommandData ¶
func (c *NodeClient) BuildCommandData(command string, data interface{}) ([]byte, error)
Builds a command data. It prepares a slice of bytes from given data
func (*NodeClient) BuildCommandDataWithAuth ¶
func (c *NodeClient) BuildCommandDataWithAuth(command string, data interface{}) ([]byte, error)
Builds a command data. It prepares a slice of bytes from given data
func (*NodeClient) CheckNodeAddress ¶
func (c *NodeClient) CheckNodeAddress(address netlib.NodeAddr) error
Check if node address looks fine
func (*NodeClient) SendAddNode ¶
func (c *NodeClient) SendAddNode(node netlib.NodeAddr) error
Request to add new node to contacts
func (*NodeClient) SendAddrList ¶
Send list of nodes addresses to other node
func (*NodeClient) SendBlock ¶
func (c *NodeClient) SendBlock(addr netlib.NodeAddr, BlockSerialised []byte) error
Send block to other node
func (*NodeClient) SendData ¶
func (c *NodeClient) SendData(addr netlib.NodeAddr, data []byte) error
Sends prepared command to a node. This doesn't wait any response
func (*NodeClient) SendDataWaitResponse ¶
func (c *NodeClient) SendDataWaitResponse(addr netlib.NodeAddr, data []byte, datapayload interface{}) error
Send data to a node and wait for response
func (*NodeClient) SendGetBalance ¶
func (c *NodeClient) SendGetBalance(addr netlib.NodeAddr, address string) (ComWalletBalance, error)
Request for list of unspent transactions outputs It can be used by wallet to see a state of balance
func (*NodeClient) SendGetBlocks ¶
func (c *NodeClient) SendGetBlocks(address netlib.NodeAddr, startfrom []byte) error
Sedn request to get list of blocks on other node.
func (*NodeClient) SendGetBlocksUpper ¶
func (c *NodeClient) SendGetBlocksUpper(address netlib.NodeAddr, startfrom []byte) error
Request for blocks but result must be upper from some starting block
func (*NodeClient) SendGetData ¶
Request for a transaction or a block to get full info by ID or Hash
func (*NodeClient) SendGetFirstBlocks ¶
func (c *NodeClient) SendGetFirstBlocks(address netlib.NodeAddr) (*ComGetFirstBlocksData, error)
Request for list of first blocks in blockchain. This is used by new nodes TODO we can use SendGetBlocksUpper and empty hash. This will e same
func (*NodeClient) SendGetHistory ¶
func (c *NodeClient) SendGetHistory(addr netlib.NodeAddr, address string) ([]ComHistoryTransaction, error)
Request for history of transaction from a wallet
func (*NodeClient) SendGetNodes ¶
func (c *NodeClient) SendGetNodes() ([]netlib.NodeAddr, error)
Request for list of nodes in contacts
func (*NodeClient) SendGetState ¶
func (c *NodeClient) SendGetState() (ComGetNodeState, error)
Request to remove a node from contacts
func (*NodeClient) SendGetUnspent ¶
func (c *NodeClient) SendGetUnspent(addr netlib.NodeAddr, address string, chaintip []byte) (ComUnspentTransactions, error)
Request for list of unspent transactions outputs It can be used by wallet to see a state of balance
func (*NodeClient) SendNewTransaction ¶
func (c *NodeClient) SendNewTransaction(addr netlib.NodeAddr, from string, tx []byte) ([]byte, error)
Send new transaction from a wallet to a node
func (*NodeClient) SendNewTransactionData ¶
func (c *NodeClient) SendNewTransactionData(addr netlib.NodeAddr, from string, txBytes []byte, signatures [][]byte) ([]byte, error)
Send new transaction from a wallet to a node
func (*NodeClient) SendRemoveNode ¶
func (c *NodeClient) SendRemoveNode(node netlib.NodeAddr) error
Request to remove a node from contacts
func (*NodeClient) SendRequestNewTransaction ¶
func (c *NodeClient) SendRequestNewTransaction(addr netlib.NodeAddr, PubKey []byte, to string, amount float64) ([]byte, [][]byte, error)
Request to prepare new transaction by wallet. It returns a transaction without signature. Wallet has to sign it and then use SendNewTransaction to send completed transaction
func (*NodeClient) SendTx ¶
func (c *NodeClient) SendTx(addr netlib.NodeAddr, tnxserialised []byte) error
Send Transaction to other node
func (*NodeClient) SendVersion ¶
func (c *NodeClient) SendVersion(addr netlib.NodeAddr, bestHeight int) error
Send own version and blockchain state to other node
func (*NodeClient) SendVoid ¶
func (c *NodeClient) SendVoid(address netlib.NodeAddr) error
Send void commant to other node It is used by a node to send to itself only when we want to stop a node And unblock port listetining
func (*NodeClient) SetAuthStr ¶
func (c *NodeClient) SetAuthStr(auth string)
Check if node address looks fine
func (*NodeClient) SetNodeAddress ¶
func (c *NodeClient) SetNodeAddress(address netlib.NodeAddr)
Set currrent node address , to include itin requests to other nodes