rpcapi

package
v0.0.0-...-9ac19d9 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: GPL-3.0 Imports: 24 Imported by: 0

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.

Types

type AccountAPI

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

func NewAccountAPI

func NewAccountAPI(b Backend) *AccountAPI

func (*AccountAPI) AccountIsExist

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

AccountIsExist

func (*AccountAPI) GetAccountBalanceByID

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

GetAccountBalanceByID

func (*AccountAPI) GetAccountBalanceByTime

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

GetAccountBalanceByTime

func (*AccountAPI) GetAccountByID

func (aapi *AccountAPI) GetAccountByID(accountID uint64) (*accountmanager.Account, error)

GetAccountByID

func (*AccountAPI) GetAccountByName

func (aapi *AccountAPI) GetAccountByName(accountName common.Name) (*accountmanager.Account, error)

GetAccountByName

func (*AccountAPI) GetAssetAmountByTime

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

GetAssetAmountByTime

func (*AccountAPI) GetAssetInfoByID

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

GetAssetInfoByID

func (*AccountAPI) GetAssetInfoByName

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

GetAssetInfoByName

func (*AccountAPI) GetCode

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

GetCode

func (*AccountAPI) GetNonce

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

GetNonce

func (*AccountAPI) GetSnapshotLast

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

GetSnapshotLast get last snapshot time

func (*AccountAPI) GetSnapshotTime

func (aapi *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, error)
	BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error)
	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) []common.Hash
	GetBadBlocks(ctx context.Context) ([]*types.Block, 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
	PeerCount() int
	Peers() []string
	BadNodesCount() int
	BadNodes() []string
	AddBadNode(url string) error
	RemoveBadNode(url string) error
	SelfNode() string
	Engine() consensus.IEngine
	APIs() []rpc.API
}

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

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

func NewFeeAPI

func NewFeeAPI(b Backend) *FeeAPI

func (*FeeAPI) GetObjectFeeByName

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

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

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

func NewPrivateBlockChainAPI(b Backend) *PrivateBlockChainAPI

NewPrivateBlockChainAPI creates a new blockchain API.

func (*PrivateBlockChainAPI) SetStatePruning

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

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

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

BadNodes returns all bad nodes.

func (*PrivateP2pAPI) BadNodesCount

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

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

func (api *PrivateP2pAPI) SelfNode() string

SelfNode return self enode url

type PrivateTxPoolAPI

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

func NewPrivateTxPoolAPI(b Backend) *PrivateTxPoolAPI

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

func (*PrivateTxPoolAPI) Content

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

Content returns the transactions contained within the transaction pool.

func (*PrivateTxPoolAPI) GetPoolTransactions

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

GetPoolTransactions txpool returns the transaction for the given hash

func (*PrivateTxPoolAPI) PendingTransactions

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

PendingTransactions returns the pending transactions that are in the transaction pool

func (*PrivateTxPoolAPI) SetGasPrice

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

SetGasPrice set txpool gas price

func (*PrivateTxPoolAPI) Status

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) (hexutil.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, error)

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{}, error)

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

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

GetChainConfig returns chain config.

func (*PublicBlockChainAPI) GetCurrentBlock

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

GetCurrentBlock returns cureent 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 interal 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 interal 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 interal 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) GetTxsByAccount

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

GetTxsByAccount return all 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) GetTxsByBloom

func (s *PublicBlockChainAPI) GetTxsByBloom(ctx context.Context, bloomByte hexutil.Bytes, blockNr rpc.BlockNumber, lookbackNum uint64) ([]common.Hash, 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-lookbackNum to blockNr

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.

Jump to

Keyboard shortcuts

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