rpc

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBalance

type AccountBalance struct {
	Balance, Receivable *RawAmount
}

AccountBalance returns how many RAW is owned and how many have not yet been received.

type AccountHistory

type AccountHistory struct {
	Type           string     `json:"type"`
	Account        string     `json:"account"`
	Amount         *RawAmount `json:"amount"`
	LocalTimestamp uint64     `json:"local_timestamp,string"`
	Height         uint64     `json:"height,string"`
	Hash           BlockHash  `json:"hash"`
}

AccountHistory reports send/receive information within a block.

type AccountHistoryRaw

type AccountHistoryRaw struct {
	Type           string     `json:"type"`
	Representative string     `json:"representative"`
	Link           BlockHash  `json:"link"`
	Balance        *RawAmount `json:"balance"`
	Previous       BlockHash  `json:"previous"`
	Subtype        string     `json:"subtype"`
	Account        string     `json:"account"`
	Amount         *RawAmount `json:"amount"`
	LocalTimestamp uint64     `json:"local_timestamp,string"`
	Height         uint64     `json:"height,string"`
	Hash           BlockHash  `json:"hash"`
	Work           HexData    `json:"work"`
	Signature      HexData    `json:"signature"`
}

AccountHistoryRaw reports all parameters of the block itself as seen in BlockCreate or other APIs returning blocks.

type AccountInfo

type AccountInfo struct {
	Frontier                   BlockHash  `json:"frontier"`
	OpenBlock                  BlockHash  `json:"open_block"`
	RepresentativeBlock        BlockHash  `json:"representative_block"`
	Balance                    *RawAmount `json:"balance"`
	ModifiedTimestamp          uint64     `json:"modified_timestamp,string"`
	BlockCount                 uint64     `json:"block_count,string"`
	ConfirmationHeight         uint64     `json:"confirmation_height,string"`
	ConfirmationHeightFrontier BlockHash  `json:"confirmation_height_frontier"`
	AccountVersion             uint64     `json:"account_version,string"`
	Representative             string     `json:"representative"`
	Weight                     *RawAmount `json:"weight"`
	Receivable                 *RawAmount `json:"receivable"`
}

AccountInfo returns frontier, open block, change representative block, balance, last modified timestamp from local database & block count for account.

type AccountReceivable

type AccountReceivable struct {
	Amount *RawAmount
	Source string
}

AccountReceivable returns amount and source account.

type Block

type Block struct {
	Type           string     `json:"type"`
	Account        string     `json:"account"`
	Previous       BlockHash  `json:"previous"`
	Representative string     `json:"representative"`
	Balance        *RawAmount `json:"balance"`
	Link           BlockHash  `json:"link"`
	LinkAsAccount  string     `json:"link_as_account"`
	Signature      HexData    `json:"signature"`
	Work           HexData    `json:"work"`
}

Block corresponds to the JSON representation of a block.

func (*Block) Hash

func (b *Block) Hash() (hash BlockHash, err error)

Hash calculates the block hash.

type BlockHash

type BlockHash []byte

BlockHash represents a block hash.

func (BlockHash) MarshalJSON

func (h BlockHash) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of h.

func (BlockHash) String

func (h BlockHash) String() string

func (*BlockHash) UnmarshalJSON

func (h *BlockHash) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON sets *h to a copy of data.

type BlockInfo

type BlockInfo struct {
	BlockAccount   string     `json:"block_account"`
	Amount         *RawAmount `json:"amount"`
	Balance        *RawAmount `json:"balance"`
	Height         uint64     `json:"height,string"`
	LocalTimestamp uint64     `json:"local_timestamp,string"`
	Confirmed      bool       `json:"confirmed,string"`
	Contents       *Block     `json:"contents"`
	Subtype        string     `json:"subtype"`
}

BlockInfo retrieves a json representation of a block.

type Client

type Client struct {
	URL        string
	AuthHeader string
	Ctx        context.Context
}

Client is used for connecting to http rpc endpoints.

func (*Client) AccountBalance

func (c *Client) AccountBalance(account string) (balance, receivable *RawAmount, err error)

AccountBalance returns how many RAW is owned and how many have not yet been received by account.

func (*Client) AccountBlockCount

func (c *Client) AccountBlockCount(account string) (blockCount uint64, err error)

AccountBlockCount gets the number of blocks for a specific account.

func (*Client) AccountHistory

func (c *Client) AccountHistory(account string, count int64, head BlockHash) (history []AccountHistory, previous BlockHash, err error)

AccountHistory reports send/receive information for an account.

func (*Client) AccountHistoryRaw

func (c *Client) AccountHistoryRaw(account string, count int64, head BlockHash) (history []AccountHistoryRaw, previous BlockHash, err error)

AccountHistoryRaw reports all parameters of the block itself as seen in BlockCreate or other APIs returning blocks.

func (*Client) AccountInfo

func (c *Client) AccountInfo(account string) (info AccountInfo, err error)

AccountInfo returns frontier, open block, change representative block, balance, last modified timestamp from local database & block count for account.

func (*Client) AccountRepresentative

func (c *Client) AccountRepresentative(account string) (representative string, err error)

AccountRepresentative returns the representative for account.

func (*Client) AccountWeight

func (c *Client) AccountWeight(account string) (weight *RawAmount, err error)

AccountWeight returns the voting weight for account.

func (*Client) AccountsBalances

func (c *Client) AccountsBalances(accounts []string) (balances map[string]*AccountBalance, err error)

AccountsBalances returns how many RAW is owned and how many have not yet been received by accounts list.

func (*Client) AccountsFrontiers

func (c *Client) AccountsFrontiers(accounts []string) (frontiers map[string]BlockHash, err error)

AccountsFrontiers returns a list of pairs of account and block hash representing the head block for accounts list.

func (*Client) AccountsReceivable

func (c *Client) AccountsReceivable(accounts []string, count int64) (receivable map[string]HashToReceivableMap, err error)

AccountsReceivable returns a list of receivable block hashes with amount and source accounts.

func (*Client) AvailableSupply

func (c *Client) AvailableSupply() (available *RawAmount, err error)

AvailableSupply returns how many raw are in the public supply.

func (*Client) BlockAccount

func (c *Client) BlockAccount(hash BlockHash) (account string, err error)

BlockAccount returns the account containing block.

func (*Client) BlockConfirm

func (c *Client) BlockConfirm(hash BlockHash) (started bool, err error)

BlockConfirm requests confirmation for block from known online representative nodes.

func (*Client) BlockCount

func (c *Client) BlockCount() (cemented, count, unchecked uint64, err error)

BlockCount reports the number of blocks in the ledger and unchecked synchronizing blocks.

func (*Client) BlockInfo

func (c *Client) BlockInfo(hash BlockHash) (info BlockInfo, err error)

BlockInfo retrieves a json representation of a block.

func (*Client) Blocks

func (c *Client) Blocks(hashes []BlockHash) (blocks map[string]*Block, err error)

Blocks retrieves a json representations of blocks.

func (*Client) BlocksInfo

func (c *Client) BlocksInfo(hashes []BlockHash) (blocks map[string]*BlockInfo, err error)

BlocksInfo retrieves a json representations of blocks in contents.

func (*Client) Chain

func (c *Client) Chain(block BlockHash, count int64) (blocks []BlockHash, err error)

Chain returns a consecutive list of block hashes in the account chain starting at block back to count (direction from frontier back to open block, from newer blocks to older). Will list all blocks back to the open block of this chain when count is set to "-1". The requested block hash is included in the answer.

func (*Client) Delegators

func (c *Client) Delegators(account string) (delegators map[string]*RawAmount, err error)

Delegators returns a list of pairs of delegator names given a representative account and its balance.

func (*Client) DelegatorsCount

func (c *Client) DelegatorsCount(account string) (count uint64, err error)

DelegatorsCount gets number of delegators for a specific representative account.

func (*Client) FrontierCount

func (c *Client) FrontierCount() (count uint64, err error)

FrontierCount reports the number of accounts in the ledger.

func (*Client) Frontiers

func (c *Client) Frontiers(account string, count int64) (frontiers map[string]BlockHash, err error)

Frontiers returns a list of pairs of account and block hash representing the head block starting at account up to count.

func (*Client) Ledger

func (c *Client) Ledger(account string, count int64, modifiedSince time.Time) (accounts map[string]AccountInfo, err error)

Ledger returns frontier, open block, change representative block, balance, last modified timestamp from local database & block count starting at account up to count.

func (*Client) Process

func (c *Client) Process(block *Block, subtype string) (hash BlockHash, err error)

Process publishes block to the network.

func (*Client) Receivable

func (c *Client) Receivable(
	account string, count int64, includeActive bool, threshold string,
) (receivable HashToReceivableMap, err error)

Receivable returns a list of block hashes which have not yet been received by this account.

func (*Client) Representatives

func (c *Client) Representatives(count int64) (representatives map[string]*RawAmount, err error)

Representatives returns a list of pairs of representative and its voting weight.

func (*Client) RepresentativesOnline

func (c *Client) RepresentativesOnline() (representatives map[string]Representative, err error)

RepresentativesOnline returns a list of online representative accounts that have voted recently.

func (*Client) Republish

func (c *Client) Republish(hash BlockHash, count, sources, destinations int64) (blocks []BlockHash, err error)

Republish rebroadcasts blocks starting at hash to the network.

func (*Client) Successors

func (c *Client) Successors(block BlockHash, count int64) (blocks []BlockHash, err error)

Successors returns a consecutive list of block hashes in the account chain starting at block up to count (direction from open block up to frontier, from older blocks to newer). Will list all blocks up to frontier (latest block) of this chain when count is set to "-1". The requested block hash is included in the answer.

func (*Client) WorkCancel

func (c *Client) WorkCancel(hash BlockHash) (err error)

WorkCancel stops generating work for block.

func (*Client) WorkGenerate

func (c *Client) WorkGenerate(hash BlockHash, difficulty HexData) (
	work, difficulty2 HexData, multiplier float64, err error,
)

WorkGenerate generates work for block. hash is the frontier of the account or in the case of an open block, the public key representation of the account.

func (*Client) WorkValidate

func (c *Client) WorkValidate(hash BlockHash, work HexData) (
	validAll, validReceive bool,
	difficulty HexData, multiplier float64, err error,
)

WorkValidate checks whether work is valid for block. Provides two values: validAll is true if the work is valid at the current network difficulty (work can be used for any block). validReceive is true if the work is valid for use in a receive block.

type HashToReceivableMap

type HashToReceivableMap map[string]AccountReceivable

HashToReceivableMap maps receivable block hashes to amount and source account.

func (*HashToReceivableMap) UnmarshalJSON

func (h *HashToReceivableMap) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON sets *h to a copy of data.

type HexData

type HexData []byte

HexData represents generic hex data.

func (HexData) MarshalJSON

func (h HexData) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of h.

func (*HexData) UnmarshalJSON

func (h *HexData) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON sets *h to a copy of data.

type RawAmount

type RawAmount struct{ big.Int }

RawAmount represents an amount of nano in RAWs.

func (*RawAmount) MarshalJSON

func (r *RawAmount) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of r.

func (*RawAmount) UnmarshalJSON

func (r *RawAmount) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON sets *r to a copy of data.

type Representative

type Representative struct{ Weight *RawAmount }

Representative returns the weight of a representative.

Jump to

Keyboard shortcuts

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