rpcapi

package
v0.0.0-...-91a82d4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: LGPL-3.0 Imports: 27 Imported by: 12

Documentation

Index

Constants

View Source
const (
	PendingBlockHeight  = BlockHeight(-2)
	LatestBlockHeight   = BlockHeight(-1)
	EarliestBlockHeight = BlockHeight(0)
)

Variables

This section is empty.

Functions

func RPCMarshalBlock

func RPCMarshalBlock(b *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error)

Types

type AdminAPI

type AdminAPI struct {
	// contains filtered or unexported fields
}

AdminAPI exposes methods for the RPC interface

func NewAdminAPI

func NewAdminAPI(b Backend) *AdminAPI

NewAdminAPI creates a new API definition for admin methods of the node itself.

func (*AdminAPI) AddPeer

func (api *AdminAPI) AddPeer(url string, reply *bool) error

AddPeer requests connecting to a remote node

func (*AdminAPI) NodeInfo

func (api *AdminAPI) NodeInfo(ignore string, reply **p2p.NodeInfo) (err error)

NodeInfo retrieves all the information we know about the host node at the protocol granularity.

func (*AdminAPI) Peers

func (api *AdminAPI) Peers(ignore string, reply *[]*p2p.PeerInfo) (err error)

Peers retrieves all the information we know about each individual peer at the protocol granularity.

func (*AdminAPI) RemovePeer

func (api *AdminAPI) RemovePeer(url string, reply *bool) error

RemovePeer disconnects from a a remote node if the connection exists

type Backend

type Backend interface {
	// blockchain backend
	BlockChain() *core.BlockChain
	CurrentBlock() *types.Block
	BlockByHeight(ctx context.Context, height BlockHeight) (*types.Block, error)
	BlockByHash(ctx context.Context, blockHash utils.Hash) (*types.Block, error)
	GetReceipts(ctx context.Context, blockHash utils.Hash) (types.Receipts, error)
	GetReceipt(ctx context.Context, txHash utils.Hash) (*types.Receipt, error)
	GetLogs(ctx context.Context, blockHash utils.Hash) ([][]*types.Log, error)
	GetTd(blockHash utils.Hash) *big.Int
	GetTransaction(txHash utils.Hash) *types.StorageTx
	// txpool backend
	SendTx(ctx context.Context, signedTx *types.Transaction) error
	GetPoolTransactions() (types.Transactions, error)
	GetPoolTransaction(txHash utils.Hash) *types.Transaction
	GetPoolNonce(ctx context.Context, addr utils.Address) (uint64, error)
	TxPoolStats() (pending int, queued int)
	TxPoolContent() (map[utils.Address]types.Transactions, map[utils.Address]types.Transactions)
	// wallet backend
	NewAccount(passphrase string) (wallet.Account, error)
	Delete(address utils.Address, passphrase string) error
	Update(address utils.Address, passphrase, newPassphrase string) error
	SignTx(addr utils.Address, tx *types.Transaction, passphrase string) (*types.Transaction, error)
	Accounts() (wallet.Accounts, error)
	ImportRawKey(privkey string, passphrase string) (utils.Address, error)
	ExportRawKey(addr utils.Address, passphrase string) (string, error)
	// forecast backend
	SuggestGasPrice(ctx context.Context) (*big.Int, error)
	// evm
	GetEVM(ctx context.Context, from utils.Address, tx *types.Transaction, state *state.StateDB, bheader *types.BlockHeader, vmCfg vm.Config) (*vm.EVM, func() error, error)

	// p2p
	AddPeer(url string) error
	RemovePeer(url string) error
	Peers() ([]*p2p.PeerInfo, error)
	NodeInfo() (*p2p.NodeInfo, error)

	//miner
	Start(int32) error
	Stop() error
	SetCoinbase(utils.Address) error

	GetConfirmedBlockNumber() (*big.Int, error)
	GetBFTConfirmedBlockNumber() (*big.Int, error)
}

Backend for rpc api

type BlockChainAPI

type BlockChainAPI struct {
	// contains filtered or unexported fields
}

BlockChainAPI exposes methods for the RPC interface

func NewBlockChainAPI

func NewBlockChainAPI(b Backend) *BlockChainAPI

NewBlockChainAPI creates a new RPC service with methods specific for the blockchain.

func (*BlockChainAPI) ExportBlocks

func (s *BlockChainAPI) ExportBlocks(args ExportBlocksArgs, reply *map[string]interface{}) error

ExportBlocks export block

func (*BlockChainAPI) GetBlockByHash

func (s *BlockChainAPI) GetBlockByHash(args GetBlockByHashArgs, reply *map[string]interface{}) error

GetBlockByHash returns the requested block.

func (*BlockChainAPI) GetBlockByHeight

func (s *BlockChainAPI) GetBlockByHeight(args GetBlockByHeightArgs, reply *map[string]interface{}) error

GetBlockByHeight returns the requested block.

func (*BlockChainAPI) GetLatestBlock

func (s *BlockChainAPI) GetLatestBlock(args GetLatestBlockArgs, reply *map[string]interface{}) error

GetLatestBlock returns the latest block.

func (*BlockChainAPI) GetLatestBlockHeight

func (s *BlockChainAPI) GetLatestBlockHeight(ingore string, reply *utils.Uint64) error

GetLatestBlockHeight returns the latest block height.

func (*BlockChainAPI) GetTransactionByHash

func (s *BlockChainAPI) GetTransactionByHash(Hash utils.Hash, reply *RPCTransaction) error

GetTransactionByHash returns the transaction for the given hash

func (*BlockChainAPI) GetTransactionReceipt

func (s *BlockChainAPI) GetTransactionReceipt(Hash utils.Hash, reply *map[string]interface{}) error

GetTransactionReceipt returns the transaction receipt for the given transaction hash.

func (*BlockChainAPI) ImportBlocks

func (s *BlockChainAPI) ImportBlocks(filename string, reply *map[string]interface{}) error

ImportBlocks import blocks

type BlockHeight

type BlockHeight int64

func (BlockHeight) Int64

func (bn BlockHeight) Int64() int64

func (*BlockHeight) MarshalJSON

func (bn *BlockHeight) MarshalJSON() (b []byte, err error)

func (*BlockHeight) UnmarshalJSON

func (bn *BlockHeight) UnmarshalJSON(data []byte) error

type CallArgs

type CallArgs struct {
	From        utils.Address
	Tos         []*utils.Address
	Gas         utils.Uint64
	GasPrice    utils.Big
	Value       utils.Big
	Data        utils.Bytes
	TxType      uint8
	BlockHeight *BlockHeight
}

CallArgs represents the arguments for a call.

type CandidateArgs

type CandidateArgs struct {
	BlockHeight *BlockHeight
	Candidate   utils.Address
}

type CandidateInfo

type CandidateInfo struct {
	CandidateAddr utils.Address `json:"candidate"`
	Weight        utils.Uint64  `json:"weight"`
	Total         *utils.Big    `json:"total"`
	Validate      *utils.Big    `json:"-"`
}

type CandidateInfos

type CandidateInfos []*CandidateInfo

func (CandidateInfos) Len

func (p CandidateInfos) Len() int

func (CandidateInfos) Less

func (p CandidateInfos) Less(i, j int) bool

func (CandidateInfos) Swap

func (p CandidateInfos) Swap(i, j int)

type DeleteArgs

type DeleteArgs struct {
	Address    utils.Address
	Passphrase string
}

type DposAPI

type DposAPI struct {
	// contains filtered or unexported fields
}

DposAPI exposes methods for the RPC interface

func NewDposAPI

func NewDposAPI(b Backend) *DposAPI

NewDposAPI creates a new API definition for dpos methods of the node itself.

func (*DposAPI) GetBFTConfirmedBlockNumber

func (api *DposAPI) GetBFTConfirmedBlockNumber(ignore string, reply *utils.Big) error

GetBFTConfirmedBlockNumber retrieves the bft latest irreversible block

func (*DposAPI) GetCandidates

func (api *DposAPI) GetCandidates(number *BlockHeight, reply *[]*CandidateInfo) error

GetCandidates retrieves the list of the candidate at specified block

func (*DposAPI) GetConfirmedBlockNumber

func (api *DposAPI) GetConfirmedBlockNumber(ignore string, reply *utils.Big) error

GetConfirmedBlockNumber retrieves the latest irreversible block

func (*DposAPI) GetDelegators

func (api *DposAPI) GetDelegators(args *CandidateArgs, reply *[]*VoterInfo) error

GetDelegators retrieves the list of the delegators of specified candidate at specified block

func (*DposAPI) GetValidators

func (api *DposAPI) GetValidators(number *BlockHeight, reply *[]utils.Address) error

GetValidators retrieves the list of the validators at specified block

func (*DposAPI) GetVoter

func (api *DposAPI) GetVoter(args *VoterInfoArgs, reply *VoterInfo) error

GetVoter retrieves voter info at specified block

func (*DposAPI) GetVoters

func (api *DposAPI) GetVoters(number *BlockHeight, reply *[]*VoterInfo) error

GetVoters retrieves the list of the voters at specified block

type ExportBlocksArgs

type ExportBlocksArgs struct {
	FileName    string
	FirstHeight *BlockHeight
	LastHeight  *BlockHeight
}

ExportBlocksArgs export blocks

type ExportRawKeyArgs

type ExportRawKeyArgs struct {
	Address    utils.Address
	Passphrase string
}

type GetBalanceArgs

type GetBalanceArgs struct {
	Address     utils.Address
	BlockHeight *BlockHeight
}

type GetBlockByHashArgs

type GetBlockByHashArgs struct {
	BlockHash utils.Hash
	FullTx    bool
}

type GetBlockByHeightArgs

type GetBlockByHeightArgs struct {
	BlockHeight *BlockHeight
	FullTx      bool
}

type GetCodeArgs

type GetCodeArgs struct {
	GetBalanceArgs
}

type GetLatestBlockArgs

type GetLatestBlockArgs struct {
	FullTx bool
}

type GetNonceArgs

type GetNonceArgs struct {
	GetBalanceArgs
}

type ImportRawKeyArgs

type ImportRawKeyArgs struct {
	PrivKeyHex string
	Passphrase string
}

type MinerAPI

type MinerAPI struct {
	// contains filtered or unexported fields
}

MinerAPI exposes methods for the RPC interface

func NewMinerAPI

func NewMinerAPI(b Backend) *MinerAPI

NewMinerAPI creates a new API definition for admin methods of the node itself.

func (*MinerAPI) SetCoinbase

func (api *MinerAPI) SetCoinbase(coinbase utils.Address, reply *bool) error

SetCoinbase the coinbase of the miner

func (*MinerAPI) Start

func (api *MinerAPI) Start(threads *int32, reply *bool) error

Start the miner

func (*MinerAPI) Stop

func (api *MinerAPI) Stop(ignore string, reply *bool) error

Stop the miner

type RPCTransaction

type RPCTransaction struct {
	BlockHash        utils.Hash       `json:"blockHash"`
	BlockHeight      *utils.Big       `json:"blockHeight"`
	Type             utils.Uint64     `json:"type"`
	From             utils.Address    `json:"from"`
	Gas              utils.Uint64     `json:"gas"`
	GasPrice         *utils.Big       `json:"gasPrice"`
	Hash             utils.Hash       `json:"hash"`
	Input            utils.Bytes      `json:"input"`
	Nonce            utils.Uint64     `json:"nonce"`
	Tos              []*utils.Address `json:"tos"`
	TransactionIndex utils.Uint       `json:"transactionIndex"`
	Value            *utils.Big       `json:"value"`
	Signature        utils.Bytes      `json:"signature"`
}

type SendTxArgs

type SendTxArgs struct {
	From       utils.Address
	Tos        []*utils.Address
	Gas        *utils.Uint64
	GasPrice   *utils.Big
	Value      *utils.Big
	Nonce      *utils.Uint64
	Data       *utils.Bytes
	TxType     *utils.Uint64
	Passphrase string
}

SendTxArgs represents the arguments to sumbit a new transaction into the transaction pool.

type TransactionPoolAPI

type TransactionPoolAPI struct {
	// contains filtered or unexported fields
}

TransactionPoolAPI exposes methods for the RPC interface

func NewTransactionPoolAPI

func NewTransactionPoolAPI(b Backend) *TransactionPoolAPI

NewTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.

func (*TransactionPoolAPI) Content

func (s *TransactionPoolAPI) Content(ignore string, reply *map[string]map[string]map[string]*RPCTransaction) error

Content returns the transactions contained within the transaction pool.

func (*TransactionPoolAPI) Status

func (s *TransactionPoolAPI) Status(ignore string, reply *map[string]utils.Uint) error

Status returns the number of pending and queued transaction in the pool.

type UpdateArgs

type UpdateArgs struct {
	Address       utils.Address
	Passphrase    string
	NewPassphrase string
}

type UranusAPI

type UranusAPI struct {
	// contains filtered or unexported fields
}

UranusAPI exposes methods for the RPC interface

func NewUranusAPI

func NewUranusAPI(b Backend) *UranusAPI

NewUranusAPI creates a new RPC service with methods specific for the uranus.

func (*UranusAPI) Call

func (u *UranusAPI) Call(args CallArgs, reply *map[string]interface{}) error

Call executes the given transaction on the state for the given block number.

func (*UranusAPI) GetBalance

func (u *UranusAPI) GetBalance(args GetBalanceArgs, reply *utils.Big) error

GetBalance returns the amount of wei for the given address in the state of the given block number

func (*UranusAPI) GetCode

func (u *UranusAPI) GetCode(args GetCodeArgs, reply *utils.Bytes) error

GetCode returns code for the given address

func (*UranusAPI) GetDelegateTimestamp

func (u *UranusAPI) GetDelegateTimestamp(args GetBalanceArgs, reply *utils.Big) error

GetDelegateTimestamp returns the locked amount of wei for the given address in the state of the given block number

func (*UranusAPI) GetLockedBalance

func (u *UranusAPI) GetLockedBalance(args GetBalanceArgs, reply *utils.Big) error

GetLockedBalance returns the locked amount of wei for the given address in the state of the given block number

func (*UranusAPI) GetNonce

func (u *UranusAPI) GetNonce(args GetNonceArgs, reply *utils.Uint64) error

GetNonce returns nonce for the given address

func (*UranusAPI) GetUnDelegateTimestamp

func (u *UranusAPI) GetUnDelegateTimestamp(args GetBalanceArgs, reply *utils.Big) error

GetUnDelegateTimestamp returns the unlocked amount of wei for the given address in the state of the given block number

func (*UranusAPI) GetUnLockedBalance

func (u *UranusAPI) GetUnLockedBalance(args GetBalanceArgs, reply *utils.Big) error

GetUnLockedBalance returns the unlocked amount of wei for the given address in the state of the given block number

func (*UranusAPI) SendRawTransaction

func (u *UranusAPI) SendRawTransaction(encodedTx utils.Bytes, reply *utils.Hash) error

SendRawTransaction will add the signed transaction to the transaction pool.

func (*UranusAPI) SignAndSendTransaction

func (u *UranusAPI) SignAndSendTransaction(args SendTxArgs, reply *utils.Hash) error

SignAndSendTransaction sign and send transaction .

func (*UranusAPI) SuggestGasPrice

func (u *UranusAPI) SuggestGasPrice(ignore string, reply *utils.Big) error

SuggestGasPrice return suggest gas price.

type VoterInfo

type VoterInfo struct {
	VoterAddr      utils.Address   `json:"voter"`
	LockedBalance  *utils.Big      `json:"lockedBalance"`
	TimeStamp      *utils.Big      `json:"timestamp"`
	CandidateAddrs []utils.Address `json:"candidates"`
}

type VoterInfoArgs

type VoterInfoArgs struct {
	BlockHeight *BlockHeight
	Delegator   utils.Address
}

type WalletAPI

type WalletAPI struct {
	// contains filtered or unexported fields
}

WalletAPI exposes methods for the RPC interface

func NewWalletAPI

func NewWalletAPI(b Backend) *WalletAPI

NewWalletAPI creates a new RPC service with methods specific for the wallet.

func (*WalletAPI) Accounts

func (w *WalletAPI) Accounts(ignore string, reply *wallet.Accounts) error

Accounts list all wallet account.

func (*WalletAPI) Delete

func (w *WalletAPI) Delete(args DeleteArgs, reply *bool) error

Delete delete a account by address and passphrase, at the same time, delete keyfile.

func (*WalletAPI) ExportRawKey

func (w *WalletAPI) ExportRawKey(args ExportRawKeyArgs, reply *string) error

ExportRawKey returns key hex.

func (*WalletAPI) ImportRawKey

func (w *WalletAPI) ImportRawKey(args ImportRawKeyArgs, reply *utils.Address) error

ImportRawKey import raw PrivateKey into walet.

func (*WalletAPI) NewAccount

func (w *WalletAPI) NewAccount(passphrase string, reply *utils.Address) error

NewAccount create a new account, and generate keyfile in keystore dir.

func (*WalletAPI) Update

func (w *WalletAPI) Update(args UpdateArgs, reply *bool) error

Update a account passphrase, at the same time, update keyfile.

Jump to

Keyboard shortcuts

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