rpcapi

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: GPL-3.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAPIs

func GetAPIs(apiBackend Backend) []rpc.API

func RPCMarshalBlock

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

RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain transaction hashes.

func RPCMarshalBlockWithPayer added in v1.0.0

func RPCMarshalBlockWithPayer(chainID *big.Int, b *types.Block, inclTx bool, fullTx bool) map[string]interface{}

Types

type AccountAPI

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

func NewAccountAPI

func NewAccountAPI(b Backend) *AccountAPI

func (*AccountAPI) AccountIsExist

func (api *AccountAPI) AccountIsExist(acctName common.Name) (bool, error)

AccountIsExist

func (*AccountAPI) GetAccountBalanceByID

func (api *AccountAPI) GetAccountBalanceByID(accountName common.Name, assetID uint64, typeID uint64) (*big.Int, error)

GetAccountBalanceByID

func (*AccountAPI) GetAccountBalanceByTime

func (api *AccountAPI) GetAccountBalanceByTime(accountName common.Name, assetID uint64, typeID uint64, time uint64) (*big.Int, error)

GetAccountBalanceByTime

func (*AccountAPI) GetAccountByID

func (api *AccountAPI) GetAccountByID(accountID uint64) (*RPCAccount, error)

GetAccountByID

func (*AccountAPI) GetAccountByName

func (api *AccountAPI) GetAccountByName(accountName common.Name) (*RPCAccount, error)

GetAccountByName

func (*AccountAPI) GetAccountExByID added in v0.0.25

func (api *AccountAPI) GetAccountExByID(accountID uint64) (*RPCAccount, error)

func (*AccountAPI) GetAccountExByName added in v0.0.25

func (api *AccountAPI) GetAccountExByName(accountName common.Name) (*RPCAccount, error)

func (*AccountAPI) GetAssetAmountByTime

func (api *AccountAPI) GetAssetAmountByTime(assetID uint64, time uint64) (*big.Int, error)

GetAssetAmountByTime

func (*AccountAPI) GetAssetInfoByID

func (api *AccountAPI) GetAssetInfoByID(assetID uint64) (*asset.AssetObject, error)

GetAssetInfoByID

func (*AccountAPI) GetAssetInfoByName

func (api *AccountAPI) GetAssetInfoByName(ctx context.Context, assetName string) (*asset.AssetObject, error)

GetAssetInfoByName

func (*AccountAPI) GetCode

func (api *AccountAPI) GetCode(accountName common.Name) (hexutil.Bytes, error)

GetCode

func (*AccountAPI) GetNonce

func (api *AccountAPI) GetNonce(accountName common.Name) (uint64, error)

GetNonce

func (*AccountAPI) GetSnapshotLast

func (api *AccountAPI) GetSnapshotLast() (uint64, error)

GetSnapshotLast get last snapshot time

func (*AccountAPI) GetSnapshotTime

func (api *AccountAPI) GetSnapshotTime(ctx context.Context, m uint64, time uint64) (uint64, error)

GetSnapshotTime m: 1 preview time 2 next time

type Backend

type Backend interface {
	// ftservice API
	ChainDb() fdb.Database
	ChainConfig() *params.ChainConfig
	SuggestPrice(ctx context.Context) (*big.Int, error)

	// BlockChain API
	CurrentBlock() *types.Block
	HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) *types.Header
	BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) *types.Block
	StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error)
	GetBlock(ctx context.Context, blockHash common.Hash) (*types.Block, error)
	GetReceipts(ctx context.Context, blockHash common.Hash) ([]*types.Receipt, error)
	GetDetailTxsLog(ctx context.Context, hash common.Hash) ([]*types.DetailTx, error)
	GetBlockDetailLog(ctx context.Context, blockNr rpc.BlockNumber) *types.BlockAndResult
	GetTd(blockHash common.Hash) *big.Int
	GetEVM(ctx context.Context, account *accountmanager.AccountManager, state *state.StateDB, from common.Name, to common.Name, assetID uint64, gasPrice *big.Int, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error)
	GetDetailTxByFilter(ctx context.Context, filterFn func(common.Name) bool, blockNr, lookbackNum uint64) []*types.DetailTx
	GetTxsByFilter(ctx context.Context, filterFn func(common.Name) bool, blockNr, lookbackNum uint64) *types.AccountTxs
	GetBadBlocks(ctx context.Context) ([]*types.Block, error)
	ForkStatus(statedb *state.StateDB) (*blockchain.ForkConfig, blockchain.ForkInfo, error)
	SetStatePruning(enable bool) (bool, uint64)

	// TxPool
	TxPool() *txpool.TxPool
	SendTx(ctx context.Context, signedTx *types.Transaction) error

	SetGasPrice(gasPrice *big.Int) bool

	//Account API
	GetAccountManager() (*accountmanager.AccountManager, error)

	//fee manager
	GetFeeManager() (*feemanager.FeeManager, error)
	GetFeeManagerByTime(time uint64) (*feemanager.FeeManager, error)

	// P2P
	AddPeer(url string) error
	RemovePeer(url string) error
	AddTrustedPeer(url string) error
	RemoveTrustedPeer(url string) error
	SeedNodes() []string
	PeerCount() int
	Peers() []string
	BadNodesCount() int
	BadNodes() []string
	AddBadNode(url string) error
	RemoveBadNode(url string) error
	SelfNode() string
	Engine() consensus.IEngine
	APIs() []rpc.API

	// Filter Log
	HeaderByHash(ctx context.Context, blockHash common.Hash) *types.Header
	GetLogs(ctx context.Context, blockHash common.Hash) ([][]*types.Log, error)
}

Backend interface provides the common API services (that are provided by both full and light clients) with access to necessary functions.

type CallArgs

type CallArgs struct {
	ActionType types.ActionType `json:"actionType"`
	From       common.Name      `json:"from"`
	To         common.Name      `json:"to"`
	AssetID    uint64           `json:"assetId"`
	Gas        uint64           `json:"gas"`
	GasPrice   *big.Int         `json:"gasPrice"`
	Value      *big.Int         `json:"value"`
	Data       hexutil.Bytes    `json:"data"`
	Remark     hexutil.Bytes    `json:"remark"`
}

type FeeAPI added in v0.0.8

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

func NewFeeAPI added in v0.0.8

func NewFeeAPI(b Backend) *FeeAPI

func (*FeeAPI) GetObjectFeeByName added in v0.0.8

func (fapi *FeeAPI) GetObjectFeeByName(ctx context.Context, objectName string, objectType uint64) (*feemanager.ObjectFee, error)

GetObjectFeeByName get object fee by name objectName: Asset Name, Contract Name, Coinbase Name objectType: Asset Type(0),Contract Type(1),Coinbase Type(2)

func (*FeeAPI) GetObjectFeeResult added in v0.0.8

func (fapi *FeeAPI) GetObjectFeeResult(ctx context.Context, startObjectFeeID uint64, count uint64, time uint64) (*feemanager.ObjectFeeResult, error)

GetObjectFeeResult get object fee infomation startObjectFeeID: object fee id, start from 1 count: The count of results obtained at one time, If it's more than 1,000, it's 1,000 time: snapshot time

type PrivateBlockChainAPI added in v0.0.12

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

PrivateBlockChainAPI provides an API to access the blockchain. It offers only methods that operate on private data that is freely available to anyone.

func NewPrivateBlockChainAPI added in v0.0.12

func NewPrivateBlockChainAPI(b Backend) *PrivateBlockChainAPI

NewPrivateBlockChainAPI creates a new blockchain API.

func (*PrivateBlockChainAPI) ForkStatus added in v0.0.28

func (s *PrivateBlockChainAPI) ForkStatus(ctx context.Context) (*RPCForkStatus, error)

func (*PrivateBlockChainAPI) SetStatePruning added in v0.0.12

func (s *PrivateBlockChainAPI) SetStatePruning(enable bool) types.BlockState

SetStatePruning start blockchain state prune

type PrivateP2pAPI

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

PrivateP2pAPI offers and API for p2p networking.

func NewPrivateP2pAPI

func NewPrivateP2pAPI(b Backend) *PrivateP2pAPI

NewPrivateP2pAPI creates a new p2p service that gives information about p2p networking.

func (*PrivateP2pAPI) AddBadNode added in v0.0.8

func (api *PrivateP2pAPI) AddBadNode(url string) (bool, error)

AddBadNode add a bad node

func (*PrivateP2pAPI) AddPeer

func (api *PrivateP2pAPI) AddPeer(url string) (bool, error)

AddPeer requests connecting to a remote node, and also maintaining the new connection at all times, even reconnecting if it is lost.

func (*PrivateP2pAPI) AddTrustedPeer

func (api *PrivateP2pAPI) AddTrustedPeer(url string) (bool, error)

AddTrustedPeer allows a remote node to always connect, even if slots are full

func (*PrivateP2pAPI) BadNodes added in v0.0.8

func (api *PrivateP2pAPI) BadNodes() []string

BadNodes returns all bad nodes.

func (*PrivateP2pAPI) BadNodesCount added in v0.0.8

func (api *PrivateP2pAPI) BadNodesCount() int

BadNodesCount returns the number of bad nodes.

func (*PrivateP2pAPI) PeerCount

func (api *PrivateP2pAPI) PeerCount() int

PeerCount return number of connected peers

func (*PrivateP2pAPI) PeerEvents

func (api *PrivateP2pAPI) PeerEvents(ctx context.Context) (*rpc.Subscription, error)

PeerEvents creates an RPC subscription which receives peer events from the node's p2p.Server

func (*PrivateP2pAPI) Peers

func (api *PrivateP2pAPI) Peers() []string

Peers return connected peers

func (*PrivateP2pAPI) RemoveBadNode added in v0.0.12

func (api *PrivateP2pAPI) RemoveBadNode(url string) (bool, error)

RemoveBadNode remove a bad node

func (*PrivateP2pAPI) RemovePeer

func (api *PrivateP2pAPI) RemovePeer(url string) (bool, error)

RemovePeer disconnects from a remote node if the connection exists

func (*PrivateP2pAPI) RemoveTrustedPeer

func (api *PrivateP2pAPI) RemoveTrustedPeer(url string) (bool, error)

RemoveTrustedPeer removes a remote node from the trusted peer set, but it does not disconnect it automatically.

func (*PrivateP2pAPI) SeedNodes added in v1.0.0

func (api *PrivateP2pAPI) SeedNodes() []string

SeedNodes returns all seed nodes.

func (*PrivateP2pAPI) SelfNode

func (api *PrivateP2pAPI) SelfNode() string

SelfNode return self enode url

type PrivateTxPoolAPI added in v0.0.12

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

PrivateTxPoolAPI offers and API for the transaction pool. It only operates on data that is non confidential.

func NewPrivateTxPoolAPI added in v0.0.12

func NewPrivateTxPoolAPI(b Backend) *PrivateTxPoolAPI

NewPrivateTxPoolAPI creates a new tx pool service that gives information about the transaction pool.

func (*PrivateTxPoolAPI) Content added in v0.0.12

func (s *PrivateTxPoolAPI) Content(fullTx bool) interface{}

Content returns the transactions contained within the transaction pool.

func (*PrivateTxPoolAPI) GetTransactions added in v1.0.0

func (s *PrivateTxPoolAPI) GetTransactions(hashes []common.Hash) []*types.RPCTransaction

GetTransactions txpool returns the transaction by the given hash.

func (*PrivateTxPoolAPI) GetTransactionsByAccount added in v1.0.0

func (s *PrivateTxPoolAPI) GetTransactionsByAccount(name common.Name, fullTx bool) interface{}

GetTransactionsByAccount txpool returns the transaction by the given account name.

func (*PrivateTxPoolAPI) PendingTransactions added in v0.0.22

func (s *PrivateTxPoolAPI) PendingTransactions(fullTx bool) (interface{}, error)

PendingTransactions returns the pending transactions that are in the transaction pool.

func (*PrivateTxPoolAPI) SetGasPrice added in v0.0.12

func (s *PrivateTxPoolAPI) SetGasPrice(gasprice *big.Int) bool

SetGasPrice set txpool gas price

func (*PrivateTxPoolAPI) Status added in v0.0.12

func (s *PrivateTxPoolAPI) Status() map[string]int

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

type PublicBlockChainAPI

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

PublicBlockChainAPI provides an API to access the blockchain. It offers only methods that operate on public data that is freely available to anyone.

func NewPublicBlockChainAPI

func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI

NewPublicBlockChainAPI creates a new blockchain API.

func (*PublicBlockChainAPI) Call

func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNr rpc.BlockNumber) (hexutil.Bytes, error)

Call executes the given transaction on the state for the given block number. It doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.

func (*PublicBlockChainAPI) EstimateGas

func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (uint64, error)

EstimateGas returns an estimate of the amount of gas needed to execute the given transaction against the current pending block.

func (*PublicBlockChainAPI) GetBadBlocks

func (s *PublicBlockChainAPI) GetBadBlocks(ctx context.Context, fullTx bool) ([]map[string]interface{}, error)

func (*PublicBlockChainAPI) GetBlockAndResultByNumber

func (s *PublicBlockChainAPI) GetBlockAndResultByNumber(ctx context.Context, blockNr rpc.BlockNumber) *types.BlockAndResult

func (*PublicBlockChainAPI) GetBlockAndResultByNumberWithPayer added in v1.0.0

func (s *PublicBlockChainAPI) GetBlockAndResultByNumberWithPayer(ctx context.Context, blockNr rpc.BlockNumber) *types.BlockAndResult

func (*PublicBlockChainAPI) GetBlockByHash

func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, blockHash common.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetBlockByNumber

func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, blockNr rpc.BlockNumber, fullTx bool) map[string]interface{}

GetBlockByNumber returns the requested block. When blockNr is -1 the chain head is returned. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetBlockByNumberWithPayer added in v1.0.0

func (s *PublicBlockChainAPI) GetBlockByNumberWithPayer(ctx context.Context, blockNr rpc.BlockNumber, fullTx bool) map[string]interface{}

func (*PublicBlockChainAPI) GetChainConfig

func (s *PublicBlockChainAPI) GetChainConfig(ctx context.Context) *params.ChainConfig

GetChainConfig returns chain config.

func (*PublicBlockChainAPI) GetCurrentBlock

func (s *PublicBlockChainAPI) GetCurrentBlock(fullTx bool) map[string]interface{}

GetCurrentBlock returns current block.

func (*PublicBlockChainAPI) GetInternalTxByAccount

func (s *PublicBlockChainAPI) GetInternalTxByAccount(ctx context.Context, acctName common.Name, blockNr rpc.BlockNumber, lookbackNum uint64) ([]*types.DetailTx, error)

GetInternalTxByAccount return all logs of internal txs, sent from or received by a specific account the range is indicate by blockNr and lookbackNum, from blocks with number from blockNr-lookbackNum to blockNr

func (*PublicBlockChainAPI) GetInternalTxByBloom

func (s *PublicBlockChainAPI) GetInternalTxByBloom(ctx context.Context, bloomByte hexutil.Bytes,
	blockNr rpc.BlockNumber, lookbackNum uint64) ([]*types.DetailTx, error)

GetInternalTxByBloom return all logs of internal txs, filtered by a bloomByte bloomByte is constructed by some quantities of account names the range is indicate by blockNr and lookbackNum, from blocks with number from blockNr-lookbackNum to blockNr

func (*PublicBlockChainAPI) GetInternalTxByHash

func (s *PublicBlockChainAPI) GetInternalTxByHash(ctx context.Context, hash common.Hash) (*types.DetailTx, error)

GetInternalTxByHash return logs of internal txs include by a transcastion

func (*PublicBlockChainAPI) GetTransactionByHash

func (s *PublicBlockChainAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) *types.RPCTransaction

GetTransactionByHash returns the transaction for the given hash

func (*PublicBlockChainAPI) GetTransactionReceipt

func (s *PublicBlockChainAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (*types.RPCReceipt, error)

GetTransactionReceipt returns the transaction receipt for the given transaction hash.

func (*PublicBlockChainAPI) GetTransactionReceiptWithPayer added in v1.0.0

func (s *PublicBlockChainAPI) GetTransactionReceiptWithPayer(ctx context.Context, hash common.Hash) (*types.RPCReceiptWithPayer, error)

func (*PublicBlockChainAPI) GetTransactions added in v0.0.28

func (s *PublicBlockChainAPI) GetTransactions(ctx context.Context, hashes []common.Hash) []*types.RPCTransaction

func (*PublicBlockChainAPI) GetTxsByAccount

func (s *PublicBlockChainAPI) GetTxsByAccount(ctx context.Context, acctName common.Name, blockNr rpc.BlockNumber, lookforwardNum uint64) (*types.AccountTxs, error)

GetTxsByAccount return all txs, sent from or received by a specific account the range is indicate by blockNr and lookforwardNum, from blocks with number from blockNr to blockNr+lookforwardNum

func (*PublicBlockChainAPI) GetTxsByBloom

func (s *PublicBlockChainAPI) GetTxsByBloom(ctx context.Context, bloomByte hexutil.Bytes, blockNr rpc.BlockNumber, lookforwardNum uint64) (*types.AccountTxs, error)

GetTxsByBloom return all txs, filtered by a bloomByte bloomByte is constructed by some quantities of account names the range is indicate by blockNr and lookbackNum, from blocks with number from blockNr to blockNr+lookforwardNum

type PublicFractalAPI

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

PublicFractalAPI offers and API for the transaction pool. It only operates on data that is non confidential.

func NewPublicFractalAPI

func NewPublicFractalAPI(b Backend) *PublicFractalAPI

NewPublicFractalAPI creates a new tx pool service that gives information about the transaction pool.

func (*PublicFractalAPI) GasPrice

func (s *PublicFractalAPI) GasPrice(ctx context.Context) (*big.Int, error)

GasPrice returns a suggestion for a gas price.

func (*PublicFractalAPI) SendRawTransaction

func (s *PublicFractalAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error)

SendRawTransaction will add the signed transaction to the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.

type RPCAccount added in v0.0.28

type RPCAccount struct {
	AcctName              common.Name                    `json:"accountName"`
	Founder               common.Name                    `json:"founder"`
	AccountID             uint64                         `json:"accountID"`
	Number                uint64                         `json:"number"`
	Nonce                 uint64                         `json:"nonce"`
	Code                  hexutil.Bytes                  `json:"code"`
	CodeHash              common.Hash                    `json:"codeHash"`
	CodeSize              uint64                         `json:"codeSize"`
	Threshold             uint64                         `json:"threshold"`
	UpdateAuthorThreshold uint64                         `json:"updateAuthorThreshold"`
	AuthorVersion         common.Hash                    `json:"authorVersion"`
	Balances              []*accountmanager.AssetBalance `json:"balances"`
	Authors               []*common.Author               `json:"authors"`
	Suicide               bool                           `json:"suicide"`
	Destroy               bool                           `json:"destroy"`
	Description           string                         `json:"description"`
}

func NewRPCAccount added in v0.0.28

func NewRPCAccount(account *accountmanager.Account) *RPCAccount

type RPCForkStatus added in v0.0.28

type RPCForkStatus struct {
	Count            uint64 `json:"count"`
	Percentage       uint64 `json:"percentage"`
	CurID            uint64 `json:"curID"`
	NexID            uint64 `json:"nextID"`
	CurIDBlockCount  uint64 `json:"curIDBlockCount"`
	NextIDBlockCount uint64 `json:"nextIDBlockCount"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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