quaiapi

package
v0.39.4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: GPL-3.0 Imports: 36 Imported by: 0

Documentation

Overview

package quaiapi implements the general Quai API functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessList

func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrHash, args TransactionArgs) (acl types.AccessList, gasUsed uint64, vmErr error, err error)

AccessList creates an access list for the given transaction. If the accesslist creation fails an error is returned. If the transaction itself fails, an vmErr is returned.

func DoCall

func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, timeout time.Duration, globalGasCap uint64) (*core.ExecutionResult, error)

func DoEstimateGas

func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap uint64) (hexutil.Uint64, error)

func GetAPIs

func GetAPIs(apiBackend Backend) []rpc.API

func RPCMarshalBlock

func RPCMarshalBlock(backend Backend, block *types.WorkObject, inclTx bool, fullTx bool, nodeLocation common.Location) (map[string]interface{}, error)

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 RPCMarshalETHBlock

func RPCMarshalETHBlock(block *types.WorkObject, inclTx bool, fullTx bool, nodeLocation common.Location) (map[string]interface{}, error)

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 RPCMarshalETHHeader

func RPCMarshalETHHeader(head *types.Header) map[string]interface{}

RPCMarshalHeader converts the given header to the RPC output .

func RPCMarshalHash

func RPCMarshalHash(hash common.Hash) (map[string]interface{}, error)

RPCMarshalHash convert the hash into a the correct interface.

func SubmitTransaction

func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (common.Hash, error)

SubmitTransaction is a helper function that submits tx to txPool and logs a message.

Types

type AccountResult

type AccountResult struct {
	Address      common.MixedcaseAddress `json:"address"`
	AccountProof []string                `json:"accountProof"`
	Balance      *hexutil.Big            `json:"balance"`
	CodeHash     common.Hash             `json:"codeHash"`
	Nonce        hexutil.Uint64          `json:"nonce"`
	StorageHash  common.Hash             `json:"storageHash"`
	StorageProof []StorageResult         `json:"storageProof"`
}

Result structs for GetProof

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 {
	// General Quai API
	EventMux() *event.TypeMux

	// General Quai API
	ChainDb() ethdb.Database
	ExtRPCEnabled() bool
	RPCGasCap() uint64    // global gas cap for eth_call over rpc: DoS protection
	RPCTxFeeCap() float64 // global tx fee cap for all transaction related APIs

	// Blockchain API
	NodeLocation() common.Location
	NodeCtx() int
	HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.WorkObject, error)
	HeaderByHash(ctx context.Context, hash common.Hash) (*types.WorkObject, error)
	HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.WorkObject, error)
	CurrentHeader() *types.WorkObject
	CurrentBlock() *types.WorkObject
	CurrentLogEntropy() *big.Int
	TotalLogEntropy(header *types.WorkObject) *big.Int
	CalcOrder(header *types.WorkObject) (*big.Int, int, error)
	BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.WorkObject, error)
	BlockByHash(ctx context.Context, hash common.Hash) (*types.WorkObject, error)
	BlockOrCandidateByHash(hash common.Hash) *types.WorkObject
	BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.WorkObject, error)
	StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.WorkObject, error)
	StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.WorkObject, error)
	AddressOutpoints(ctx context.Context, address common.Address) ([]*types.OutpointAndDenomination, error)
	GetOutpointsByAddressAndRange(ctx context.Context, address common.Address, start, end uint32) ([]*types.OutpointAndDenomination, error)
	UTXOsByAddress(ctx context.Context, address common.Address) ([]*types.UtxoEntry, error)
	GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)
	GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.WorkObject, parent *types.WorkObject, vmConfig *vm.Config) (*vm.EVM, func() error, error)
	SetCurrentExpansionNumber(expansionNumber uint8)
	SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
	SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
	SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription
	WriteBlock(block *types.WorkObject)
	Append(header *types.WorkObject, manifest types.BlockManifest, domTerminus common.Hash, domOrigin bool, newInboundEtxs types.Transactions) (types.Transactions, error)
	DownloadBlocksInManifest(hash common.Hash, manifest types.BlockManifest, entropy *big.Int)
	ConstructLocalMinedBlock(header *types.WorkObject) (*types.WorkObject, error)
	InsertBlock(ctx context.Context, block *types.WorkObject) (int, error)
	PendingBlock() *types.WorkObject
	RequestDomToAppendOrFetch(hash common.Hash, entropy *big.Int, order int)
	NewGenesisPendingHeader(pendingHeader *types.WorkObject, domTerminus common.Hash, hash common.Hash) error
	GetPendingHeader() (*types.WorkObject, error)
	GetPendingBlockBody(workShare *types.WorkObjectHeader) *types.WorkObject
	GetTxsFromBroadcastSet(hash common.Hash) (types.Transactions, error)
	GetManifest(blockHash common.Hash) (types.BlockManifest, error)
	GetSubManifest(slice common.Location, blockHash common.Hash) (types.BlockManifest, error)
	AddPendingEtxs(pEtxs types.PendingEtxs) error
	AddPendingEtxsRollup(pEtxsRollup types.PendingEtxsRollup) error
	PendingBlockAndReceipts() (*types.WorkObject, types.Receipts)
	GenerateRecoveryPendingHeader(pendingHeader *types.WorkObject, checkpointHashes types.Termini) error
	GetPendingEtxsRollupFromSub(hash common.Hash, location common.Location) (types.PendingEtxsRollup, error)
	GetPendingEtxsFromSub(hash common.Hash, location common.Location) (types.PendingEtxs, error)
	ProcessingState() bool
	GetSlicesRunning() []common.Location
	SetSubInterface(subInterface core.CoreBackend, location common.Location)
	AddGenesisPendingEtxs(block *types.WorkObject)
	SubscribeExpansionEvent(ch chan<- core.ExpansionEvent) event.Subscription
	WriteGenesisBlock(block *types.WorkObject, location common.Location)
	SendWorkShare(workShare *types.WorkObjectHeader) error
	CheckIfValidWorkShare(workShare *types.WorkObjectHeader) types.WorkShareValidity
	SetDomInterface(domInterface core.CoreBackend)
	BroadcastWorkShare(workShare *types.WorkObjectShareView, location common.Location) error
	GetMaxTxInWorkShare() uint64
	GetExpansionNumber() uint8
	SuggestFinalityDepth(ctx context.Context, qiValue *big.Int, correlatedRisk *big.Int) (*big.Int, error)
	WorkShareDistance(wo *types.WorkObject, ws *types.WorkObjectHeader) (*big.Int, error)
	GeneratePendingHeader(block *types.WorkObject, fill bool) (*types.WorkObject, error)
	MakeFullPendingHeader(primePh, regionPh, zonePh *types.WorkObject) *types.WorkObject
	CheckInCalcOrderCache(hash common.Hash) (*big.Int, int, bool)
	AddToCalcOrderCache(hash common.Hash, order int, intrinsicS *big.Int)
	GetPrimeBlock(blockHash common.Hash) *types.WorkObject
	consensus.ChainHeaderReader
	TxMiningEnabled() bool
	GetWorkShareThreshold() int
	GetMinerEndpoints() []string

	BadHashExistsInChain() bool
	IsBlockHashABadHash(hash common.Hash) bool

	// Validator methods that checks the sanity of the Body
	SanityCheckWorkObjectBlockViewBody(wo *types.WorkObject) error
	SanityCheckWorkObjectHeaderViewBody(wo *types.WorkObject) error
	SanityCheckWorkObjectShareViewBody(wo *types.WorkObject) error
	ApplyPoWFilter(wo *types.WorkObject) pubsub.ValidationResult

	// Transaction pool API
	SendTx(ctx context.Context, signedTx *types.Transaction) error
	SendRemoteTxs(txs types.Transactions) []error
	GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)
	GetPoolTransactions() (types.Transactions, error)
	GetPoolTransaction(txHash common.Hash) *types.Transaction
	GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)
	Stats() (pending int, queued int, qi int)
	TxPoolContent() (map[common.InternalAddress]types.Transactions, map[common.InternalAddress]types.Transactions)
	TxPoolContentFrom(addr common.Address) (types.Transactions, types.Transactions)
	GetMinGasPrice() *big.Int
	GetPoolGasPrice() *big.Int
	SendTxToSharingClients(tx *types.Transaction)

	// Filter API
	BloomStatus() (uint64, uint64)
	GetLogs(ctx context.Context, blockHash common.Hash) ([][]*types.Log, error)
	ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
	SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription
	SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription
	SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription
	SubscribePendingHeaderEvent(ch chan<- *types.WorkObject) event.Subscription

	ChainConfig() *params.ChainConfig
	Engine() consensus.Engine

	// Logger
	Logger() *log.Logger

	// P2P apis
	BroadcastBlock(block *types.WorkObject, location common.Location) error
	BroadcastHeader(header *types.WorkObject, location common.Location) error
}

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

type ExecutionResult

type ExecutionResult struct {
	Gas         uint64         `json:"gas"`
	Failed      bool           `json:"failed"`
	ReturnValue string         `json:"returnValue"`
	StructLogs  []StructLogRes `json:"structLogs"`
}

ExecutionResult groups all structured logs emitted by the EVM while replaying a transaction in debug mode as well as transaction execution status, the amount of gas used and the return value

type OverrideAccount

type OverrideAccount struct {
	Nonce     *hexutil.Uint64              `json:"nonce"`
	Code      *hexutil.Bytes               `json:"code"`
	Balance   **hexutil.Big                `json:"balance"`
	State     *map[common.Hash]common.Hash `json:"state"`
	StateDiff *map[common.Hash]common.Hash `json:"stateDiff"`
}

OverrideAccount indicates the overriding fields of account during the execution of a message call. Note, state and stateDiff can't be specified at the same time. If state is set, message execution will only use the data in the given state. Otherwise if statDiff is set, all diff will be applied first and then execute the call message.

type PrivateDebugAPI

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

PrivateDebugAPI is the collection of Quai APIs exposed over the private debugging endpoint.

func NewPrivateDebugAPI

func NewPrivateDebugAPI(b Backend) *PrivateDebugAPI

NewPrivateDebugAPI creates a new API definition for the private debug methods of the Quai service.

func (*PrivateDebugAPI) ChaindbCompact

func (api *PrivateDebugAPI) ChaindbCompact() error

ChaindbCompact flattens the entire key-value database into a single level, removing all unused slots and merging all keys.

func (*PrivateDebugAPI) ChaindbProperty

func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error)

ChaindbProperty returns leveldb properties of the key-value database.

type PublicBlockChainAPI

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

PublicBlockChainAPI provides an API to access the Quai 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 Quai blockchain API.

func (*PublicBlockChainAPI) BlockNumber

func (s *PublicBlockChainAPI) BlockNumber() hexutil.Uint64

BlockNumber returns the block number of the chain head.

func (*PublicBlockChainAPI) Call

func (s *PublicBlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride) (hexutil.Bytes, error)

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

Additionally, the caller can specify a batch of contract for fields overriding.

Note, this function doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.

func (*PublicBlockChainAPI) ChainId

func (api *PublicBlockChainAPI) ChainId() (*hexutil.Big, error)

ChainId is the replay-protection chain id for the current Quai chain config.

func (*PublicBlockChainAPI) CreateAccessList

func (s *PublicBlockChainAPI) CreateAccessList(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (*accessListResult, error)

CreateAccessList creates an AccessList for the given transaction. Reexec and BlockNrOrHash can be specified to create the accessList on top of a certain state.

func (*PublicBlockChainAPI) EstimateGas

func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (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) GetBalance

func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.AddressBytes, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)

GetBalance returns the amount of wei for the given address in the state of the given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*PublicBlockChainAPI) GetBlockByHash

func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, hash 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, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber returns the requested canonical block.

  • When blockNr is -1 the chain head is returned.
  • When blockNr is -2 the pending chain head is returned.
  • When fullTx is true all transactions in the block are returned, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetCode

func (s *PublicBlockChainAPI) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetCode returns the code stored at the given address in the state for the given block number.

func (*PublicBlockChainAPI) GetHeaderByHash

func (s *PublicBlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) map[string]interface{}

GetHeaderByHash returns the requested header by hash.

func (*PublicBlockChainAPI) GetHeaderByNumber

func (s *PublicBlockChainAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)

GetHeaderByNumber returns the requested canonical block header. * When blockNr is -1 the chain head is returned. * When blockNr is -2 the pending chain head is returned.

func (*PublicBlockChainAPI) GetProof

func (s *PublicBlockChainAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*AccountResult, error)

GetProof returns the Merkle-proof for a given account and optionally some storage keys.

func (*PublicBlockChainAPI) GetStorageAt

func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetStorageAt returns the storage from the state at the given address, key and block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*PublicBlockChainAPI) GetUncleByBlockHashAndIndex

func (s *PublicBlockChainAPI) GetUncleByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockHashAndIndex returns the uncle block for the given block hash and index. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetUncleByBlockNumberAndIndex

func (s *PublicBlockChainAPI) GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockNumberAndIndex returns the uncle block for the given block hash and index. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetUncleCountByBlockHash

func (s *PublicBlockChainAPI) GetUncleCountByBlockHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint

GetUncleCountByBlockHash returns number of uncles in the block for the given block hash

func (*PublicBlockChainAPI) GetUncleCountByBlockNumber

func (s *PublicBlockChainAPI) GetUncleCountByBlockNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint

GetUncleCountByBlockNumber returns number of uncles in the block for the given block number

type PublicBlockChainQuaiAPI

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

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

func NewPublicBlockChainQuaiAPI

func NewPublicBlockChainQuaiAPI(b Backend) *PublicBlockChainQuaiAPI

NewPublicBlockChainQuaiAPI creates a new Quai blockchain API.

func (*PublicBlockChainQuaiAPI) BaseFee added in v0.29.0

func (s *PublicBlockChainQuaiAPI) BaseFee(ctx context.Context, txType bool) (*hexutil.Big, error)

BaseFee returns the base fee for a tx to be included in the next block. If txType is set to "true" returns the Quai base fee in units of Wei. If txType is set to "false" returns the Qi base fee in units of Qit.

func (*PublicBlockChainQuaiAPI) BlockNumber

func (s *PublicBlockChainQuaiAPI) BlockNumber() hexutil.Uint64

BlockNumber returns the block number of the chain head.

func (*PublicBlockChainQuaiAPI) CalcOrder added in v0.31.0

func (*PublicBlockChainQuaiAPI) Call

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

Additionally, the caller can specify a batch of contract for fields overriding.

Note, this function doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.

func (*PublicBlockChainQuaiAPI) ChainId

func (api *PublicBlockChainQuaiAPI) ChainId() (*hexutil.Big, error)

ChainId is the replay-protection chain id for the current Quai chain config.

func (*PublicBlockChainQuaiAPI) CreateAccessList

func (s *PublicBlockChainQuaiAPI) CreateAccessList(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (*accessListResult, error)

CreateAccessList creates an AccessList for the given transaction. Reexec and BlockNrOrHash can be specified to create the accessList on top of a certain state.

func (*PublicBlockChainQuaiAPI) EstimateFeeForQi added in v0.29.0

func (s *PublicBlockChainQuaiAPI) EstimateFeeForQi(ctx context.Context, args TransactionArgs) (*hexutil.Big, error)

EstimateFeeForQi returns an estimate of the amount of Qi in qits needed to execute the given transaction against the current pending block.

func (*PublicBlockChainQuaiAPI) EstimateGas

func (s *PublicBlockChainQuaiAPI) EstimateGas(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error)

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

func (*PublicBlockChainQuaiAPI) GetBalance

func (s *PublicBlockChainQuaiAPI) GetBalance(ctx context.Context, address common.MixedcaseAddress, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)

GetBalance returns the amount of wei for the given address in the state of the given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*PublicBlockChainQuaiAPI) GetBlockByHash

func (s *PublicBlockChainQuaiAPI) GetBlockByHash(ctx context.Context, hash 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 (*PublicBlockChainQuaiAPI) GetBlockByNumber

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

GetBlockByNumber returns the requested canonical block.

  • When blockNr is -1 the chain head is returned.
  • When blockNr is -2 the pending chain head is returned.
  • When fullTx is true all transactions in the block are returned, otherwise only the transaction hash is returned.

func (*PublicBlockChainQuaiAPI) GetBlockOrCandidateByHash added in v0.31.0

func (s *PublicBlockChainQuaiAPI) GetBlockOrCandidateByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error)

func (*PublicBlockChainQuaiAPI) GetCode

GetCode returns the code stored at the given address in the state for the given block number.

func (*PublicBlockChainQuaiAPI) GetContractSize added in v0.32.0

func (s *PublicBlockChainQuaiAPI) GetContractSize(ctx context.Context, address common.AddressBytes, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)

GetContractSize gives the size of the contract at the block hash or number

func (*PublicBlockChainQuaiAPI) GetHeaderByHash

func (s *PublicBlockChainQuaiAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) map[string]interface{}

GetHeaderByHash returns the requested header by hash.

func (*PublicBlockChainQuaiAPI) GetHeaderByNumber

func (s *PublicBlockChainQuaiAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)

GetHeaderByNumber returns the requested canonical block header. * When blockNr is -1 the chain head is returned. * When blockNr is -2 the pending chain head is returned.

func (*PublicBlockChainQuaiAPI) GetLatestUTXOSetSize added in v0.37.0

func (s *PublicBlockChainQuaiAPI) GetLatestUTXOSetSize(ctx context.Context) (hexutil.Uint64, error)

func (*PublicBlockChainQuaiAPI) GetOutPointsByAddressAndRange added in v0.39.0

func (s *PublicBlockChainQuaiAPI) GetOutPointsByAddressAndRange(ctx context.Context, address common.Address, start, end hexutil.Uint64) (map[string][]interface{}, error)

func (*PublicBlockChainQuaiAPI) GetOutpointsByAddress added in v0.30.0

func (s *PublicBlockChainQuaiAPI) GetOutpointsByAddress(ctx context.Context, address common.Address) ([]interface{}, error)

func (*PublicBlockChainQuaiAPI) GetPendingHeader

func (s *PublicBlockChainQuaiAPI) GetPendingHeader(ctx context.Context) (hexutil.Bytes, error)

func (*PublicBlockChainQuaiAPI) GetProof

func (s *PublicBlockChainQuaiAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*AccountResult, error)

GetProof returns the Merkle-proof for a given account and optionally some storage keys.

func (*PublicBlockChainQuaiAPI) GetProtocolExpansionNumber added in v0.29.0

func (s *PublicBlockChainQuaiAPI) GetProtocolExpansionNumber() hexutil.Uint

func (*PublicBlockChainQuaiAPI) GetStorageAt

func (s *PublicBlockChainQuaiAPI) GetStorageAt(ctx context.Context, address common.MixedcaseAddress, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetStorageAt returns the storage from the state at the given address, key and block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*PublicBlockChainQuaiAPI) GetUTXO added in v0.39.0

func (s *PublicBlockChainQuaiAPI) GetUTXO(ctx context.Context, txHash common.Hash, index hexutil.Uint64) (map[string]interface{}, error)

func (*PublicBlockChainQuaiAPI) GetUncleByBlockHashAndIndex

func (s *PublicBlockChainQuaiAPI) GetUncleByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockHashAndIndex returns the uncle block for the given block hash and index. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainQuaiAPI) GetUncleByBlockNumberAndIndex

func (s *PublicBlockChainQuaiAPI) GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockNumberAndIndex returns the uncle block for the given block hash and index. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainQuaiAPI) GetUncleCountByBlockHash

func (s *PublicBlockChainQuaiAPI) GetUncleCountByBlockHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint

GetUncleCountByBlockHash returns number of uncles in the block for the given block hash

func (*PublicBlockChainQuaiAPI) GetUncleCountByBlockNumber

func (s *PublicBlockChainQuaiAPI) GetUncleCountByBlockNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint

GetUncleCountByBlockNumber returns number of uncles in the block for the given block number

func (*PublicBlockChainQuaiAPI) ListRunningChains added in v0.29.0

func (s *PublicBlockChainQuaiAPI) ListRunningChains() []common.Location

ListRunningChains returns the running locations where the node is serving data.

func (*PublicBlockChainQuaiAPI) NodeLocation

func (api *PublicBlockChainQuaiAPI) NodeLocation() []hexutil.Uint64

NodeLocation is the access call to the location of the node.

func (*PublicBlockChainQuaiAPI) QiRateAtBlock added in v0.29.0

func (s *PublicBlockChainQuaiAPI) QiRateAtBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, qiAmount hexutil.Big) *hexutil.Big

Calculate the amount of Quai that Qi can be converted to. Expect the current Header and the Qi amount in "qits", returns the quai amount in "its"

func (*PublicBlockChainQuaiAPI) QuaiRateAtBlock added in v0.29.0

func (s *PublicBlockChainQuaiAPI) QuaiRateAtBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, quaiAmount hexutil.Big) *hexutil.Big

Calculate the amount of Qi that Quai can be converted to. Expect the current Header and the Quai amount in "its", returns the Qi amount in "qits"

func (*PublicBlockChainQuaiAPI) ReceiveMinedHeader

func (s *PublicBlockChainQuaiAPI) ReceiveMinedHeader(ctx context.Context, raw hexutil.Bytes) error

ReceiveMinedHeader will run checks on the block and add to canonical chain if valid.

func (*PublicBlockChainQuaiAPI) ReceiveRawWorkShare added in v0.32.0

func (s *PublicBlockChainQuaiAPI) ReceiveRawWorkShare(ctx context.Context, raw hexutil.Bytes) error

func (*PublicBlockChainQuaiAPI) ReceiveWorkShare added in v0.29.0

func (s *PublicBlockChainQuaiAPI) ReceiveWorkShare(ctx context.Context, workShare *types.WorkObjectHeader) error

func (*PublicBlockChainQuaiAPI) SuggestFinalityDepth added in v0.32.0

func (s *PublicBlockChainQuaiAPI) SuggestFinalityDepth(ctx context.Context, qiValue hexutil.Uint64, correlatedRisk hexutil.Uint64) (hexutil.Uint64, error)

type PublicDebugAPI

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

PublicDebugAPI is the collection of Quai APIs exposed over the public debugging endpoint.

func NewPublicDebugAPI

func NewPublicDebugAPI(b Backend) *PublicDebugAPI

NewPublicDebugAPI creates a new API definition for the public debug methods of the Quai service.

func (*PublicDebugAPI) GetBlockRlp

func (api *PublicDebugAPI) GetBlockRlp(ctx context.Context, number uint64) (string, error)

GetBlockRlp retrieves the RLP encoded for of a single block.

func (*PublicDebugAPI) PrintBlock

func (api *PublicDebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error)

PrintBlock retrieves a block and returns its pretty printed form.

func (*PublicDebugAPI) SeedHash

func (api *PublicDebugAPI) SeedHash(ctx context.Context, number uint64) (string, error)

SeedHash retrieves the seed hash of a block.

type PublicNetAPI

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

PublicNetAPI offers network related RPC methods

func (*PublicNetAPI) Listening

func (s *PublicNetAPI) Listening() bool

Listening returns an indication if the node is listening for network connections.

func (*PublicNetAPI) Version

func (s *PublicNetAPI) Version() string

Version returns the current Quai protocol version.

type PublicQuaiAPI

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

PublicQuaiAPI provides an API to access Quai related information. It offers only methods that operate on public data that is freely available to anyone.

func NewPublicQuaiAPI

func NewPublicQuaiAPI(b Backend) *PublicQuaiAPI

NewPublicQuaiAPI creates a new Quai protocol API.

func (*PublicQuaiAPI) GasPrice

func (s *PublicQuaiAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)

GasPrice returns a suggestion for a gas price for legacy transactions.

func (*PublicQuaiAPI) MinerTip added in v0.34.0

func (s *PublicQuaiAPI) MinerTip(ctx context.Context) *hexutil.Big

MinerTip returns the gas price of the pool

type PublicQuaiAPI_Deprecated

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

PublicQuaiAPI_Deprecated provides an API to access Quai related information. It offers only methods that operate on public data that is freely available to anyone.

func NewPublicQuaiAPI_Deprecated

func NewPublicQuaiAPI_Deprecated(b Backend) *PublicQuaiAPI_Deprecated

NewPublicQuaiAPI_Deprecated creates a new Quai protocol API.

func (*PublicQuaiAPI_Deprecated) GasPrice

GasPrice returns a suggestion for a gas price for legacy transactions.

type PublicTransactionPoolAPI

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

PublicTransactionPoolAPI exposes methods for the RPC interface

func NewPublicTransactionPoolAPI

func NewPublicTransactionPoolAPI(b Backend, nonceLock *AddrLocker) *PublicTransactionPoolAPI

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

func (*PublicTransactionPoolAPI) GetBlockTransactionCountByHash

func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint

GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.

func (*PublicTransactionPoolAPI) GetBlockTransactionCountByNumber

func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint

GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.

func (*PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex

func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes

GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index.

func (*PublicTransactionPoolAPI) GetRawTransactionByBlockNumberAndIndex

func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) hexutil.Bytes

GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index.

func (*PublicTransactionPoolAPI) GetRawTransactionByHash

func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)

GetRawTransactionByHash returns the bytes of the transaction for the given hash.

func (*PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex

func (s *PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint, nodeLocation common.Location) *RPCTransaction

GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.

func (*PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex

func (s *PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint, nodeLocation common.Location) *RPCTransaction

GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.

func (*PublicTransactionPoolAPI) GetTransactionByHash

func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error)

GetTransactionByHash returns the transaction for the given hash

func (*PublicTransactionPoolAPI) GetTransactionCount

func (s *PublicTransactionPoolAPI) GetTransactionCount(ctx context.Context, addr common.MixedcaseAddress, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)

GetTransactionCount returns the number of transactions the given address has sent for the given block number

func (*PublicTransactionPoolAPI) GetTransactionReceipt

func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt returns the transaction receipt for the given transaction hash.

func (*PublicTransactionPoolAPI) ReceiveTxFromPoolSharingClient added in v0.39.0

func (s *PublicTransactionPoolAPI) ReceiveTxFromPoolSharingClient(ctx context.Context, input hexutil.Bytes) error

func (*PublicTransactionPoolAPI) SendRawTransaction

func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, input 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]*RPCTransaction

Content returns the transactions contained within the transaction pool.

func (*PublicTxPoolAPI) ContentFrom

func (s *PublicTxPoolAPI) ContentFrom(addr common.Address) map[string]map[string]*RPCTransaction

ContentFrom returns the transactions contained within the transaction pool.

func (*PublicTxPoolAPI) Inspect

func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string]string

Inspect retrieves the content of the transaction pool and flattens it into an easily inspectable list.

func (*PublicTxPoolAPI) Status

func (s *PublicTxPoolAPI) Status() map[string]hexutil.Uint

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

type PublicWorkSharesAPI added in v0.32.0

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

func NewPublicWorkSharesAPI added in v0.32.0

func NewPublicWorkSharesAPI(txpoolAPi *PublicTransactionPoolAPI, b Backend) *PublicWorkSharesAPI

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

func (*PublicWorkSharesAPI) GetWork added in v0.32.0

GetWork returns the current workObjectHeader and the workThreshold to recognize a share

func (*PublicWorkSharesAPI) GetWorkShareThreshold added in v0.32.0

func (s *PublicWorkSharesAPI) GetWorkShareThreshold(ctx context.Context) (int, error)

GetWorkShareThreshold returns the minimal WorkShareThreshold that this node will accept

func (*PublicWorkSharesAPI) ReceiveSubWorkshare added in v0.32.0

func (s *PublicWorkSharesAPI) ReceiveSubWorkshare(ctx context.Context, input hexutil.Bytes) error

func (*PublicWorkSharesAPI) SendUnworkedTransaction added in v0.32.0

func (s *PublicWorkSharesAPI) SendUnworkedTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error)

SendWorkedTransaction will check that the transaction in the form of a worked WorkObject fufills the work threshold before adding it to the transaction pool.

type RPCTransaction

type RPCTransaction struct {
	BlockHash         *common.Hash             `json:"blockHash"`
	BlockNumber       *hexutil.Big             `json:"blockNumber"`
	From              *common.MixedcaseAddress `json:"from,omitempty"`
	Gas               hexutil.Uint64           `json:"gas,omitempty"`
	MinerTip          *hexutil.Big             `json:"minerTip,omitempty"`
	GasPrice          *hexutil.Big             `json:"gasPrice,omitempty"`
	Hash              common.Hash              `json:"hash,omitempty"`
	Input             hexutil.Bytes            `json:"input"`
	Nonce             hexutil.Uint64           `json:"nonce"`
	To                *common.MixedcaseAddress `json:"to,omitempty"`
	TransactionIndex  *hexutil.Uint64          `json:"transactionIndex"`
	Value             *hexutil.Big             `json:"value,omitempty"`
	Type              hexutil.Uint64           `json:"type"`
	Accesses          *types.AccessList        `json:"accessList,omitempty"`
	ChainID           *hexutil.Big             `json:"chainId,omitempty"`
	V                 *hexutil.Big             `json:"v,omitempty"`
	R                 *hexutil.Big             `json:"r,omitempty"`
	S                 *hexutil.Big             `json:"s,omitempty"`
	TxIn              []RPCTxIn                `json:"inputs,omitempty"`
	TxOut             []RPCTxOut               `json:"outputs,omitempty"`
	UTXOSignature     hexutil.Bytes            `json:"utxoSignature,omitempty"`
	OriginatingTxHash *common.Hash             `json:"originatingTxHash,omitempty"`
	ETXIndex          *hexutil.Uint64          `json:"etxIndex,omitempty"`
	ETxType           *hexutil.Uint64          `json:"etxType,omitempty"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

type RPCTxIn added in v0.30.0

type RPCTxIn struct {
	PreviousOutPoint types.OutpointJSON `json:"previousOutPoint"`
	PubKey           hexutil.Bytes      `json:"pubKey"`
}

type RPCTxOut added in v0.30.0

type RPCTxOut struct {
	Denomination hexutil.Uint  `json:"denomination"`
	Address      hexutil.Bytes `json:"address"`
	Lock         *hexutil.Big  `json:"lock"`
}

type StateOverride

type StateOverride map[common.AddressBytes]OverrideAccount

StateOverride is the collection of overridden accounts.

func (*StateOverride) Apply

func (diff *StateOverride) Apply(state *state.StateDB, nodeLocation common.Location) error

Apply overrides the fields of specified accounts into the given state.

type StorageResult

type StorageResult struct {
	Key   string       `json:"key"`
	Value *hexutil.Big `json:"value"`
	Proof []string     `json:"proof"`
}

type StructLogRes

type StructLogRes struct {
	Pc      uint64             `json:"pc"`
	Op      string             `json:"op"`
	Gas     uint64             `json:"gas"`
	GasCost uint64             `json:"gasCost"`
	Depth   int                `json:"depth"`
	Error   string             `json:"error,omitempty"`
	Stack   *[]string          `json:"stack,omitempty"`
	Memory  *[]string          `json:"memory,omitempty"`
	Storage *map[string]string `json:"storage,omitempty"`
}

StructLogRes stores a structured log emitted by the EVM while replaying a transaction in debug mode

func FormatLogs

func FormatLogs(logs []vm.StructLog) []StructLogRes

FormatLogs formats EVM returned structured logs for json output

type TransactionArgs

type TransactionArgs struct {
	From     *common.Address `json:"from"`
	To       *common.Address `json:"to"`
	Gas      *hexutil.Uint64 `json:"gas"`
	GasPrice *hexutil.Big    `json:"gasPrice"`
	MinerTip *hexutil.Big    `json:"minerTip"`
	Value    *hexutil.Big    `json:"value"`
	Nonce    *hexutil.Uint64 `json:"nonce"`

	// We accept "data" and "input" for backwards-compatibility reasons.
	// "input" is the newer name and should be preferred by clients.
	Data  *hexutil.Bytes `json:"data"`
	Input *hexutil.Bytes `json:"input"`

	// Introduced by AccessListTxType transaction.
	AccessList *types.AccessList `json:"accessList,omitempty"`
	ChainID    *hexutil.Big      `json:"chainId,omitempty"`

	// Support for Qi (UTXO) transaction
	TxIn   types.TxIns  `json:"txIn,omitempty"`
	TxOut  types.TxOuts `json:"txOut,omitempty"`
	TxType uint8        `json:"txType,omitempty"`
}

TransactionArgs represents the arguments to construct a new transaction or a message call.

func (*TransactionArgs) CalculateQiTxGas added in v0.29.0

func (args *TransactionArgs) CalculateQiTxGas(qiScalingFactor float64, location common.Location) (hexutil.Uint64, error)

CalculateQiTxGas calculates the gas usage of a Qi transaction.

func (*TransactionArgs) ToMessage

func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, nodeLocation common.Location) (types.Message, error)

ToMessage converts th transaction arguments to the Message type used by the core evm. This method is used in calls and traces that do not require a real live transaction.

type TxWorker added in v0.32.0

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

func StartTxWorker added in v0.32.0

func StartTxWorker(engine consensus.Engine, endpoints []string, location common.Location, api *PublicWorkSharesAPI, workShareThreshold int) *TxWorker

func (*TxWorker) AddTransaction added in v0.32.0

func (worker *TxWorker) AddTransaction(tx *types.Transaction) error

func (*TxWorker) StopWorkers added in v0.32.0

func (worker *TxWorker) StopWorkers()

Jump to

Keyboard shortcuts

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