rpcapi

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxIDCount = uint64(1000)
)

Variables

View Source
var (
	ErrGetAccounManagerErr = errors.New("get account manager failure")
)

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(ctx context.Context, acctName common.Name) (bool, error)

AccountIsExist

func (*AccountAPI) GetAccountBalanceByID

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

GetAccountBalanceByID

func (*AccountAPI) GetAccountBalanceByTime

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

GetAccountBalanceByTime

func (*AccountAPI) GetAccountByID

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

GetAccountByID

func (*AccountAPI) GetAccountByName

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

GetAccountByName

func (*AccountAPI) GetAssetAmountByTime

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

GetAssetAmountByTime

func (*AccountAPI) GetAssetInfoByID

func (aapi *AccountAPI) GetAssetInfoByID(ctx context.Context, 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(ctx context.Context, accountName common.Name) (hexutil.Bytes, error)

GetCode

func (*AccountAPI) GetNonce

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

GetNonce

func (*AccountAPI) GetSnapshotLast

func (aapi *AccountAPI) GetSnapshotLast(ctx context.Context) (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 AddrLocker

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

func (*AddrLocker) LockAddr

func (l *AddrLocker) LockAddr(address common.Address)

LockAddr locks an account's mutex. This is used to prevent another tx getting the same nonce until the lock is released. The mutex prevents the (an identical nonce) from being read again during the time that the first transaction is being signed.

func (*AddrLocker) UnlockAddr

func (l *AddrLocker) UnlockAddr(address common.Address)

UnlockAddr unlocks the mutex of the given account.

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, 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 rpc.BlockNumber, lookbackNum uint64) []*types.DetailTx
	GetTxsByFilter(ctx context.Context, filterFn func(common.Name) bool, blockNr rpc.BlockNumber, lookbackNum uint64) []common.Hash
	GetBadBlocks(ctx context.Context) ([]*types.Block, error)
	SetStatePruning(enable bool) (bool, uint64)

	// TxPool API
	SendTx(ctx context.Context, signedTx *types.Transaction) error
	GetPoolTransactions() ([]*types.Transaction, error)
	GetPoolTransaction(txHash common.Hash) *types.Transaction
	Stats() (pending int, queued int)
	TxPoolContent() (map[common.Name][]*types.Transaction, map[common.Name][]*types.Transaction)

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

	SetGasPrice(gasPrice *big.Int) bool

	//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
	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 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 (aapi *FeeAPI) GetObjectFeeByName(ctx context.Context, objectName string, objectType uint64) (*feemanager.ObjectFee, error)

GetObjectFeeByName get object fee by name

func (*FeeAPI) GetObjectFeeResult added in v0.0.8

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

GetObjectFeeByIDRange get object fee by name

func (*FeeAPI) GetObjectFeeResultByTime added in v0.0.8

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

GetFeeManagerByTime

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) 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) 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 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() map[string]interface{}

GetChainConfig returns chain config.

func (*PublicBlockChainAPI) GetCurrentBlock

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

GetCurrentBlock returns cureent block.

func (*PublicBlockChainAPI) GetGenesis added in v0.0.8

func (s *PublicBlockChainAPI) GetGenesis() map[string]interface{}

GetGenesis returns genesis config.

func (*PublicBlockChainAPI) GetInternalTxByAccount

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

func (*PublicBlockChainAPI) GetInternalTxByBloom

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

func (*PublicBlockChainAPI) GetInternalTxByHash

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

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)

func (*PublicBlockChainAPI) GetTxsByBloom

func (s *PublicBlockChainAPI) GetTxsByBloom(ctx context.Context, bloomByte hexutil.Bytes, blockNr rpc.BlockNumber, lookbackNum uint64) ([]common.Hash, error)

func (*PublicBlockChainAPI) SetStatePruning added in v0.0.8

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

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 PublicTxPoolAPI

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

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

func NewPublicTxPoolAPI

func NewPublicTxPoolAPI(b Backend) *PublicTxPoolAPI

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

func (*PublicTxPoolAPI) Content

func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string]*types.RPCTransaction

Content returns the transactions contained within the transaction pool.

func (*PublicTxPoolAPI) SetGasPrice

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

SetGasPrice set gas price limit

func (*PublicTxPoolAPI) Status

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

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

Jump to

Keyboard shortcuts

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