rpc

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: LGPL-3.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// blockchain
	GetBlockByNumberNew      = "GetBlockByNumberNew"
	GetBlockByNumber         = "GetBlockByNumber"
	GetBlockByHashNew        = "GetBlockByHashNew"
	GetBlockByHash           = "GetBlockByHash"
	GetBlocks                = "GetBlocks"
	IsLastBlock              = "IsLastBlock"
	EpochLastBlock           = "EpochLastBlock"
	GetBlockSigners          = "GetBlockSigners"
	GetBlockReceipts         = "GetBlockReceipts"
	GetBlockSignerKeys       = "GetBlockSignerKeys"
	IsBlockSigner            = "IsBlockSigner"
	GetSignedBlocks          = "GetSignedBlocks"
	GetEpoch                 = "GetEpoch"
	GetLeader                = "GetLeader"
	GetShardingStructure     = "GetShardingStructure"
	GetBalanceByBlockNumber  = "GetBalanceByBlockNumber"
	LatestHeader             = "LatestHeader"
	GetLatestChainHeaders    = "GetLatestChainHeaders"
	GetLastCrossLinks        = "GetLastCrossLinks"
	GetHeaderByNumber        = "GetHeaderByNumber"
	GetHeaderByNumberRLPHex  = "GetHeaderByNumberRLPHex"
	GetProof                 = "GetProof"
	GetCurrentUtilityMetrics = "GetCurrentUtilityMetrics"
	GetSuperCommittees       = "GetSuperCommittees"
	GetCurrentBadBlocks      = "GetCurrentBadBlocks"
	GetTotalSupply           = "GetTotalSupply"
	GetCirculatingSupply     = "GetCirculatingSupply"
	GetStakingNetworkInfo    = "GetStakingNetworkInfo"
	InSync                   = "InSync"
	BeaconInSync             = "BeaconInSync"
	SetNodeToBackupMode      = "SetNodeToBackupMode"

	// contract
	GetCode      = "GetCode"
	GetStorageAt = "GetStorageAt"
	Call         = "Call"
	DoEvmCall    = "DoEVMCall"

	// net
	PeerCount  = "PeerCount"
	NetVersion = "Version"

	// pool
	SendRawTransaction             = "SendRawTransaction"
	SendRawStakingTransaction      = "SendRawStakingTransaction"
	GetPoolStats                   = "GetPoolStats"
	PendingTransactions            = "PendingTransactions"
	PendingStakingTransactions     = "PendingStakingTransactions"
	GetCurrentTransactionErrorSink = "GetCurrentTransactionErrorSink"
	GetCurrentStakingErrorSink     = "GetCurrentStakingErrorSink"
	GetPendingCXReceipts           = "GetPendingCXReceipts"

	// staking
	GetTotalStaking                         = "GetTotalStaking"
	GetMedianRawStakeSnapshot               = "GetMedianRawStakeSnapshot"
	GetElectedValidatorAddresses            = "GetElectedValidatorAddresses"
	GetValidators                           = "GetValidators"
	GetAllValidatorAddresses                = "GetAllValidatorAddresses"
	GetValidatorKeys                        = "GetValidatorKeys"
	GetAllValidatorInformation              = "GetAllValidatorInformation"
	GetAllValidatorInformationByBlockNumber = "GetAllValidatorInformationByBlockNumber"
	GetValidatorInformation                 = "GetValidatorInformation"
	GetValidatorInformationByBlockNumber    = "GetValidatorInformationByBlockNumber"
	GetValidatorsStakeByBlockNumber         = "GetValidatorsStakeByBlockNumber"
	GetValidatorSelfDelegation              = "GetValidatorSelfDelegation"
	GetValidatorTotalDelegation             = "GetValidatorTotalDelegation"
	GetAllDelegationInformation             = "GetAllDelegationInformation"
	GetDelegationsByDelegator               = "GetDelegationsByDelegator"
	GetDelegationsByDelegatorByBlockNumber  = "GetDelegationsByDelegatorByBlockNumber"
	GetDelegationsByValidator               = "GetDelegationsByValidator"
	GetDelegationByDelegatorAndValidator    = "GetDelegationByDelegatorAndValidator"
	GetAvailableRedelegationBalance         = "GetAvailableRedelegationBalance"

	// tracer
	TraceChain         = "TraceChain"
	TraceBlockByNumber = "TraceBlockByNumber"
	TraceBlockByHash   = "TraceBlockByHash"
	TraceBlock         = "TraceBlock"
	TraceTransaction   = "TraceTransaction"
	TraceCall          = "TraceCall"

	// tracer parity
	Block       = "Block"
	Transaction = "Transaction"

	// transaction
	GetAccountNonce                            = "GetAccountNonce"
	GetTransactionCount                        = "GetTransactionCount"
	GetTransactionsCount                       = "GetTransactionsCount"
	GetStakingTransactionsCount                = "GetStakingTransactionsCount"
	RpcEstimateGas                             = "EstimateGas"
	GetTransactionByHash                       = "GetTransactionByHash"
	GetStakingTransactionByHash                = "GetStakingTransactionByHash"
	GetTransactionsHistory                     = "GetTransactionsHistory"
	GetStakingTransactionsHistory              = "GetStakingTransactionsHistory"
	GetBlockTransactionCountByNumber           = "GetBlockTransactionCountByNumber"
	GetBlockTransactionCountByHash             = "GetBlockTransactionCountByHash"
	GetTransactionByBlockNumberAndIndex        = "GetTransactionByBlockNumberAndIndex"
	GetTransactionByBlockHashAndIndex          = "GetTransactionByBlockHashAndIndex"
	GetBlockStakingTransactionCountByNumber    = "GetBlockStakingTransactionCountByNumber"
	GetBlockStakingTransactionCountByHash      = "GetBlockStakingTransactionCountByHash"
	GetStakingTransactionByBlockNumberAndIndex = "GetStakingTransactionByBlockNumberAndIndex"
	GetStakingTransactionByBlockHashAndIndex   = "GetStakingTransactionByBlockHashAndIndex"
	GetTransactionReceipt                      = "GetTransactionReceipt"
	GetCXReceiptByHash                         = "GetCXReceiptByHash"
	ResendCx                                   = "ResendCx"

	// filters
	NewPendingTransactionFilter = "NewPendingTransactionFilter"
	NewPendingTransactions      = "NewPendingTransactions"
	NewBlockFilter              = "NewBlockFilter"
	NewHeads                    = "NewHeads"
	GetFilterChanges            = "GetFilterChanges"
	Logs                        = "Logs"
	NewFilter                   = "NewFilter"
	GetLogs                     = "GetLogs"
	UninstallFilter             = "UninstallFilter"
	GetFilterLogs               = "GetFilterLogs"

	// Web3
	ClientVersion = "ClientVersion"
)

rpc name const

View Source
const (
	QueryNumber       = "query_number"
	FailedNumber      = "failed_number"
	RateLimitedNumber = "rate_limited_number"
)

info type const

View Source
const (
	// APIVersion used for DApp's, bumped after RPC refactor (7/2020)
	APIVersion = "1.1"
	// CallTimeout is the timeout given to all contract calls
	CallTimeout = 5 * time.Second
	// LogTag is the tag found in the log for all RPC logs
	LogTag = "[RPC]"
	// HTTPPortOffset ..
	HTTPPortOffset = 500
	// WSPortOffset ..
	WSPortOffset = 800
)
View Source
const (
	// LatestBlockNumber is the alias to rpc latest block number
	LatestBlockNumber = BlockNumber(rpc.LatestBlockNumber)

	// PendingBlockNumber is the alias to rpc pending block number
	PendingBlockNumber = BlockNumber(rpc.PendingBlockNumber)
)
View Source
const (
	DefaultRateLimiterWaitTimeout = 5 * time.Second
)

Variables

View Source
var (
	// ErrInvalidLogLevel when invalid log level is provided
	ErrInvalidLogLevel = errors.New("invalid log level")
	// ErrIncorrectChainID when ChainID does not match running node
	ErrIncorrectChainID = errors.New("incorrect chain id")
	// ErrInvalidChainID when ChainID of signer does not match that of running node
	ErrInvalidChainID = errors.New("invalid chain id for signer")
	// ErrNotBeaconShard when rpc is called on not beacon chain node
	ErrNotBeaconShard = errors.New("cannot call this rpc on non beaconchain node")
	// ErrRequestedBlockTooHigh when given block is greater than latest block number
	ErrRequestedBlockTooHigh = errors.New("requested block number greater than current block number")
	// ErrUnknownRPCVersion when rpc method has an unknown or unhandled version
	ErrUnknownRPCVersion = errors.New("API service has an unknown version")
	// ErrTransactionNotFound when attempting to get a transaction that does not exist or has not been finalized
	ErrTransactionNotFound = errors.New("transaction not found")
)
View Source
var (
	// HTTPModules ..
	HTTPModules = []string{"hmy", "hmyv2", "eth", "debug", "trace", netNamespace, netV1Namespace, netV2Namespace, web3Namespace, "explorer"}
	// WSModules ..
	WSModules = []string{"hmy", "hmyv2", "eth", "debug", "trace", netNamespace, netV1Namespace, netV2Namespace, web3Namespace, "web3"}
)
View Source
var (
	// ErrNotAvailable to indicate the RPC is not ready for public use
	ErrNotAvailable = errors.New("RPC not available yet")
)

Functions

func DoEVMCall

func DoEVMCall(
	ctx context.Context, hmy *hmy.Harmony, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash,
	timeout time.Duration,
) (core.ExecutionResult, error)

DoEVMCall executes an EVM call

func DoMetricRPCQueryInfo

func DoMetricRPCQueryInfo(rpcName string, infoType string)

func DoMetricRPCRequest

func DoMetricRPCRequest(rpcName string) *prometheus.Timer

func DoRPCRequestDuration

func DoRPCRequestDuration(rpcName string, timer *prometheus.Timer)

func EstimateGas

func EstimateGas(ctx context.Context, hmy *hmy.Harmony, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap *big.Int) (uint64, error)

EstimateGas - estimate gas cost for a given operation

func NewPrivateDebugAPI

func NewPrivateDebugAPI(hmy *hmy.Harmony, version Version) rpc.API

NewPrivateDebugAPI creates a new API for the RPC interface TODO(dm): expose public via config

func NewPublicBlockchainAPI

func NewPublicBlockchainAPI(hmy *hmy.Harmony, version Version, limiterEnable bool, limit int) rpc.API

NewPublicBlockchainAPI creates a new API for the RPC interface

func NewPublicContractAPI

func NewPublicContractAPI(hmy *hmy.Harmony, version Version, limiterEnable bool, limit int) rpc.API

NewPublicContractAPI creates a new API for the RPC interface

func NewPublicDebugAPI

func NewPublicDebugAPI(hmy *hmy.Harmony, version Version) rpc.API

NewPublicDebugAPI creates a new API for the RPC interface

func NewPublicHarmonyAPI

func NewPublicHarmonyAPI(hmy *hmy.Harmony, version Version) rpc.API

NewPublicHarmonyAPI creates a new API for the RPC interface

func NewPublicNetAPI

func NewPublicNetAPI(net p2p.Host, chainID uint64, version Version) rpc.API

NewPublicNetAPI creates a new net API instance.

func NewPublicPoolAPI

func NewPublicPoolAPI(hmy *hmy.Harmony, version Version, limiterEnable bool, limit int) rpc.API

NewPublicPoolAPI creates a new API for the RPC interface

func NewPublicStakingAPI

func NewPublicStakingAPI(hmy *hmy.Harmony, version Version) rpc.API

NewPublicStakingAPI creates a new API for the RPC interface

func NewPublicTraceAPI

func NewPublicTraceAPI(hmy *hmy.Harmony, version Version) rpc.API

NewPublicTraceAPI creates a new API for the RPC interface

func NewPublicTransactionAPI

func NewPublicTransactionAPI(hmy *hmy.Harmony, version Version) rpc.API

NewPublicTransactionAPI creates a new API for the RPC interface

func NewPublicWeb3API

func NewPublicWeb3API() rpc.API

NewPublicWeb3API creates a new web3 API instance.

func StartServers

func StartServers(hmy *hmy.Harmony, apis []rpc.API, config nodeconfig.RPCServerConfig, rpcOpt harmony.RpcOptConfig) error

StartServers starts the http & ws servers

func StopServers

func StopServers() error

StopServers stops the http & ws servers

Types

type AccountResult

type AccountResult struct {
	Address      common.Address  `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 AddressOrList

type AddressOrList struct {
	Address     *common.Address
	AddressList []common.Address
}

AddressOrList represents an address or a list of addresses

func (*AddressOrList) UnmarshalJSON

func (aol *AddressOrList) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON defines the input parsing of AddressOrList

type BlockNumber

type BlockNumber rpc.BlockNumber

BlockNumber ..

func (BlockNumber) EthBlockNumber

func (bn BlockNumber) EthBlockNumber() rpc.BlockNumber

EthBlockNumber ..

func (BlockNumber) Int64

func (bn BlockNumber) Int64() int64

Int64 ..

func (*BlockNumber) UnmarshalJSON

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

UnmarshalJSON converts a hex string or integer to a block number

type CallArgs

type CallArgs struct {
	From     *common.Address `json:"from"`
	To       *common.Address `json:"to"`
	Gas      *hexutil.Uint64 `json:"gas"`
	GasPrice *hexutil.Big    `json:"gasPrice"`
	Value    *hexutil.Big    `json:"value"`
	Data     *hexutil.Bytes  `json:"data"`
}

CallArgs represents the arguments for a call.

func (*CallArgs) ToMessage

func (args *CallArgs) ToMessage(globalGasCap *big.Int) types.Message

ToMessage converts CallArgs to the Message type used by the core evm Adapted from go-ethereum/internal/ethapi/api.go

type Delegation

type Delegation struct {
	ValidatorAddress string         `json:"validator_address"`
	DelegatorAddress string         `json:"delegator_address"`
	Amount           *big.Int       `json:"amount"`
	Reward           *big.Int       `json:"reward"`
	Undelegations    []Undelegation `json:"Undelegations"`
}

Delegation represents a particular delegation to a validator

func (Delegation) IntoStructuredResponse

func (d Delegation) IntoStructuredResponse() StructuredResponse

type HeaderInformation

type HeaderInformation struct {
	BlockHash        common.Hash       `json:"blockHash"`
	BlockNumber      uint64            `json:"blockNumber"`
	ShardID          uint32            `json:"shardID"`
	Leader           string            `json:"leader"`
	ViewID           uint64            `json:"viewID"`
	Epoch            uint64            `json:"epoch"`
	Timestamp        string            `json:"timestamp"`
	UnixTime         uint64            `json:"unixtime"`
	LastCommitSig    string            `json:"lastCommitSig"`
	LastCommitBitmap string            `json:"lastCommitBitmap"`
	VRF              string            `json:"vrf"`
	VRFProof         string            `json:"vrfProof"`
	CrossLinks       *types.CrossLinks `json:"crossLinks,omitempty"`
}

HeaderInformation represents the latest consensus information

func NewHeaderInformation

func NewHeaderInformation(header *block.Header, leader string) *HeaderInformation

NewHeaderInformation returns the header information that will serialize to the RPC representation.

type PrivateDebugService

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

PrivateDebugService Internal JSON RPC for debugging purpose

func (*PrivateDebugService) ConsensusCurViewID

func (s *PrivateDebugService) ConsensusCurViewID(
	ctx context.Context,
) uint64

ConsensusCurViewID return the current view ID to RPC

func (*PrivateDebugService) ConsensusViewChangingID

func (s *PrivateDebugService) ConsensusViewChangingID(
	ctx context.Context,
) uint64

ConsensusViewChangingID return the current view changing ID to RPC

func (*PrivateDebugService) GetConfig

GetConfig get harmony config

func (*PrivateDebugService) GetConsensusMode

func (s *PrivateDebugService) GetConsensusMode(
	ctx context.Context,
) string

GetConsensusMode return the current consensus mode

func (*PrivateDebugService) GetConsensusPhase

func (s *PrivateDebugService) GetConsensusPhase(
	ctx context.Context,
) string

GetConsensusPhase return the current consensus mode

func (*PrivateDebugService) GetLastSigningPower

func (s *PrivateDebugService) GetLastSigningPower(
	ctx context.Context,
) (float64, error)

GetLastSigningPower get last signed power

type PublicBlockchainService

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

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

func (*PublicBlockchainService) Accounts

func (s *PublicBlockchainService) Accounts() []common.Address

Accounts returns the collection of accounts this node manages While this JSON-RPC method is supported, it will not return any accounts. Similar to e.g. Infura "unlocking" accounts isn't supported. Instead, users should send already signed raw transactions using hmy_sendRawTransaction or eth_sendRawTransaction

func (*PublicBlockchainService) BeaconInSync

func (s *PublicBlockchainService) BeaconInSync(ctx context.Context) (bool, error)

BeaconInSync returns if beacon chain is syncing

func (*PublicBlockchainService) BlockNumber

func (s *PublicBlockchainService) BlockNumber(ctx context.Context) (interface{}, error)

BlockNumber returns the block number of the chain head.

func (*PublicBlockchainService) ChainId

func (s *PublicBlockchainService) ChainId(ctx context.Context) (interface{}, error)

ChainId returns the chain id of the chain - required by MetaMask

func (*PublicBlockchainService) EpochLastBlock

func (s *PublicBlockchainService) EpochLastBlock(ctx context.Context, epoch uint64) (uint64, error)

EpochLastBlock returns epoch last block.

func (*PublicBlockchainService) GetBalanceByBlockNumber

func (s *PublicBlockchainService) GetBalanceByBlockNumber(
	ctx context.Context, address string, blockNumber BlockNumber,
) (interface{}, error)

GetBalanceByBlockNumber returns balance by block number

func (*PublicBlockchainService) GetBlockByHash

func (s *PublicBlockchainService) GetBlockByHash(
	ctx context.Context, blockHash common.Hash, opts interface{},
) (response interface{}, err 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. When withSigners in BlocksArgs is true it shows block signers for this block in list of one addresses.

func (*PublicBlockchainService) GetBlockByHashNew

func (s *PublicBlockchainService) GetBlockByHashNew(
	ctx context.Context, blockHash common.Hash, blockArgs *rpc_common.BlockArgs,
) (interface{}, error)

GetBlockByHashNew is an alias for GetBlocksByHash using rpc_common.BlockArgs

func (*PublicBlockchainService) GetBlockByNumber

func (s *PublicBlockchainService) GetBlockByNumber(
	ctx context.Context, blockNumber BlockNumber, opts interface{},
) (response interface{}, err error)

GetBlockByNumber returns the requested block. When blockNum 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. When withSigners in BlocksArgs is true it shows block signers for this block in list of one addresses.

func (*PublicBlockchainService) GetBlockByNumberNew

func (s *PublicBlockchainService) GetBlockByNumberNew(
	ctx context.Context, blockNum BlockNumber, blockArgs *rpc_common.BlockArgs,
) (interface{}, error)

GetBlockByNumberNew is an alias for GetBlockByNumber using rpc_common.BlockArgs

func (*PublicBlockchainService) GetBlockReceipts

func (s *PublicBlockchainService) GetBlockReceipts(
	ctx context.Context, blockHash common.Hash,
) ([]StructuredResponse, error)

GetBlockReceipts returns all transaction receipts for a particular block.

func (*PublicBlockchainService) GetBlockSignerKeys

func (s *PublicBlockchainService) GetBlockSignerKeys(
	ctx context.Context, blockNumber BlockNumber,
) ([]string, error)

GetBlockSignerKeys returns bls public keys that signed the block.

func (*PublicBlockchainService) GetBlockSigners

func (s *PublicBlockchainService) GetBlockSigners(
	ctx context.Context, blockNumber BlockNumber,
) ([]string, error)

GetBlockSigners returns signers for a particular block.

func (*PublicBlockchainService) GetBlocks

func (s *PublicBlockchainService) GetBlocks(
	ctx context.Context, blockNumberStart BlockNumber,
	blockNumberEnd BlockNumber, blockArgs *rpc_common.BlockArgs,
) ([]interface{}, error)

GetBlocks method returns blocks in range blockStart, blockEnd just like GetBlockByNumber but all at once.

func (*PublicBlockchainService) GetCirculatingSupply

func (s *PublicBlockchainService) GetCirculatingSupply(
	ctx context.Context,
) (numeric.Dec, error)

GetCirculatingSupply ...

func (*PublicBlockchainService) GetCurrentBadBlocks

func (s *PublicBlockchainService) GetCurrentBadBlocks(
	ctx context.Context,
) ([]StructuredResponse, error)

GetCurrentBadBlocks ..

func (*PublicBlockchainService) GetCurrentUtilityMetrics

func (s *PublicBlockchainService) GetCurrentUtilityMetrics(
	ctx context.Context,
) (StructuredResponse, error)

GetCurrentUtilityMetrics ..

func (*PublicBlockchainService) GetEpoch

func (s *PublicBlockchainService) GetEpoch(ctx context.Context) (interface{}, error)

GetEpoch returns current epoch.

func (*PublicBlockchainService) GetFullHeader

func (s *PublicBlockchainService) GetFullHeader(
	ctx context.Context, blockNumber BlockNumber,
) (response StructuredResponse, err error)

func (*PublicBlockchainService) GetHeaderByNumber

func (s *PublicBlockchainService) GetHeaderByNumber(
	ctx context.Context, blockNumber BlockNumber,
) (StructuredResponse, error)

GetHeaderByNumber returns block header at given number

func (*PublicBlockchainService) GetHeaderByNumberRLPHex

func (s *PublicBlockchainService) GetHeaderByNumberRLPHex(
	ctx context.Context, blockNumber BlockNumber,
) (string, error)

GetHeaderByNumberRLPHex returns block header at given number by `hex(rlp(header))`

func (s *PublicBlockchainService) GetLastCrossLinks(
	ctx context.Context,
) ([]StructuredResponse, error)

GetLastCrossLinks ..

func (*PublicBlockchainService) GetLatestChainHeaders

func (s *PublicBlockchainService) GetLatestChainHeaders(
	ctx context.Context,
) (StructuredResponse, error)

GetLatestChainHeaders ..

func (*PublicBlockchainService) GetLeader

func (s *PublicBlockchainService) GetLeader(ctx context.Context) (string, error)

GetLeader returns current shard leader.

func (*PublicBlockchainService) GetProof

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

GetHeaderByNumberRLPHex returns block header at given number by `hex(rlp(header))`

func (*PublicBlockchainService) GetShardID

func (s *PublicBlockchainService) GetShardID(ctx context.Context) (int, error)

GetShardID returns shard ID of the requested node.

func (*PublicBlockchainService) GetShardingStructure

func (s *PublicBlockchainService) GetShardingStructure(
	ctx context.Context,
) ([]StructuredResponse, error)

GetShardingStructure returns an array of sharding structures.

func (*PublicBlockchainService) GetSignedBlocks

func (s *PublicBlockchainService) GetSignedBlocks(
	ctx context.Context, address string,
) (interface{}, error)

GetSignedBlocks returns how many blocks a particular validator signed for last blocksPeriod (1 epoch's worth of blocks).

func (*PublicBlockchainService) GetStakingNetworkInfo

func (s *PublicBlockchainService) GetStakingNetworkInfo(
	ctx context.Context,
) (StructuredResponse, error)

GetStakingNetworkInfo ..

func (*PublicBlockchainService) GetSuperCommittees

func (s *PublicBlockchainService) GetSuperCommittees(
	ctx context.Context,
) (StructuredResponse, error)

GetSuperCommittees ..

func (*PublicBlockchainService) GetTotalSupply

func (s *PublicBlockchainService) GetTotalSupply(
	ctx context.Context,
) (numeric.Dec, error)

GetTotalSupply ..

func (*PublicBlockchainService) InSync

func (s *PublicBlockchainService) InSync(ctx context.Context) (bool, error)

InSync returns if shard chain is syncing

func (*PublicBlockchainService) IsBlockSigner

func (s *PublicBlockchainService) IsBlockSigner(
	ctx context.Context, blockNumber BlockNumber, address string,
) (bool, error)

IsBlockSigner returns true if validator with address signed blockNum block.

func (*PublicBlockchainService) IsLastBlock

func (s *PublicBlockchainService) IsLastBlock(ctx context.Context, blockNum uint64) (bool, error)

IsLastBlock checks if block is last epoch block.

func (*PublicBlockchainService) LatestHeader

LatestHeader returns the latest header information

func (*PublicBlockchainService) SetNodeToBackupMode

func (s *PublicBlockchainService) SetNodeToBackupMode(ctx context.Context, isBackup bool) (bool, error)

type PublicContractService

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

PublicContractService provides an API to access Harmony's contract services. It offers only methods that operate on public data that is freely available to anyone.

func (*PublicContractService) Call

func (s *PublicContractService) Call(
	ctx context.Context, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash,
) (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 (*PublicContractService) GetCode

func (s *PublicContractService) GetCode(
	ctx context.Context, addr string, blockNrOrHash rpc.BlockNumberOrHash,
) (hexutil.Bytes, error)

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

func (*PublicContractService) GetStorageAt

func (s *PublicContractService) GetStorageAt(
	ctx context.Context, addr string, 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.

type PublicDebugService

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

PublicDebugService Internal JSON RPC for debugging purpose

func (*PublicDebugService) SetLogVerbosity

func (s *PublicDebugService) SetLogVerbosity(ctx context.Context, level int) (map[string]interface{}, error)

SetLogVerbosity Sets log verbosity on runtime curl -H "Content-Type: application/json" -d '{"method":"hmy_setLogVerbosity","params":[5],"id":1}' http://127.0.0.1:9500

type PublicHarmonyService

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

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

func (*PublicHarmonyService) GasPrice

func (s *PublicHarmonyService) GasPrice(ctx context.Context) (interface{}, error)

GasPrice returns a suggestion for a gas price. Note that the return type is an interface to account for the different versions

func (*PublicHarmonyService) GetNodeMetadata

func (s *PublicHarmonyService) GetNodeMetadata(
	ctx context.Context,
) (StructuredResponse, error)

GetNodeMetadata produces a NodeMetadata record, data is from the answering RPC node

func (s *PublicHarmonyService) GetNumPendingCrossLinks() (int, error)

GetNumPendingCrossLinks returns length of hmy.BlockChain.ReadPendingCrossLinks()

func (*PublicHarmonyService) GetPeerInfo

func (s *PublicHarmonyService) GetPeerInfo(
	ctx context.Context,
) (StructuredResponse, error)

GetPeerInfo produces a NodePeerInfo record

func (*PublicHarmonyService) ProtocolVersion

func (s *PublicHarmonyService) ProtocolVersion(
	ctx context.Context,
) (interface{}, error)

ProtocolVersion returns the current Harmony protocol version this node supports Note that the return type is an interface to account for the different versions

func (*PublicHarmonyService) Syncing

func (s *PublicHarmonyService) Syncing(
	ctx context.Context,
) (interface{}, error)

Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not yet received the latest block headers from its pears. In case it is synchronizing: - startingBlock: block number this node started to synchronise from - currentBlock: block number this node is currently importing - highestBlock: block number of the highest block header this node has received from peers - pulledStates: number of state entries processed until now - knownStates: number of known state entries that still need to be pulled

type PublicNetService

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

PublicNetService offers network related RPC methods

func (*PublicNetService) PeerCount

func (s *PublicNetService) PeerCount(ctx context.Context) (interface{}, error)

PeerCount returns the number of connected peers Note that the return type is an interface to account for the different versions

func (*PublicNetService) Version

func (s *PublicNetService) Version(ctx context.Context) interface{}

Version returns the network version, i.e. ChainID identifying which network we are using

type PublicParityTracerService

type PublicParityTracerService struct {
	*PublicTracerService
}

func (*PublicParityTracerService) Block

func (s *PublicParityTracerService) Block(ctx context.Context, number rpc.BlockNumber) (interface{}, error)

trace_block RPC

func (*PublicParityTracerService) Transaction

func (s *PublicParityTracerService) Transaction(ctx context.Context, hash common.Hash) (interface{}, error)

type PublicPoolService

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

PublicPoolService provides an API to access the Harmony node's transaction pool. It offers only methods that operate on public data that is freely available to anyone.

func (*PublicPoolService) GetCurrentStakingErrorSink

func (s *PublicPoolService) GetCurrentStakingErrorSink(
	ctx context.Context,
) ([]StructuredResponse, error)

GetCurrentStakingErrorSink ..

func (*PublicPoolService) GetCurrentTransactionErrorSink

func (s *PublicPoolService) GetCurrentTransactionErrorSink(
	ctx context.Context,
) ([]StructuredResponse, error)

GetCurrentTransactionErrorSink ..

func (*PublicPoolService) GetNumPendingCXReceipts

func (s *PublicPoolService) GetNumPendingCXReceipts(
	ctx context.Context,
) (int, error)

GetNumPendingCXReceipts ..

func (*PublicPoolService) GetPendingCXReceipts

func (s *PublicPoolService) GetPendingCXReceipts(
	ctx context.Context,
) ([]StructuredResponse, error)

GetPendingCXReceipts ..

func (*PublicPoolService) GetPoolStats

func (s *PublicPoolService) GetPoolStats(
	ctx context.Context,
) (StructuredResponse, error)

GetPoolStats returns stats for the tx-pool

func (*PublicPoolService) PendingStakingTransactions

func (s *PublicPoolService) PendingStakingTransactions(
	ctx context.Context,
) ([]StructuredResponse, error)

PendingStakingTransactions returns the staking transactions that are in the transaction pool

func (*PublicPoolService) PendingTransactions

func (s *PublicPoolService) PendingTransactions(
	ctx context.Context,
) ([]StructuredResponse, error)

PendingTransactions returns the plain transactions that are in the transaction pool

func (*PublicPoolService) SendRawStakingTransaction

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

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

func (*PublicPoolService) SendRawTransaction

func (s *PublicPoolService) 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 PublicStakingService

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

PublicStakingService provides an API to access Harmony's staking services. It offers only methods that operate on public data that is freely available to anyone.

func (*PublicStakingService) GetAllDelegationInformation

func (s *PublicStakingService) GetAllDelegationInformation(
	ctx context.Context, page int,
) ([][]StructuredResponse, error)

GetAllDelegationInformation returns delegation information about `validatorsPageSize` validators, starting at `page*validatorsPageSize`. TODO(dm): optimize with single flight

func (*PublicStakingService) GetAllValidatorAddresses

func (s *PublicStakingService) GetAllValidatorAddresses(
	ctx context.Context,
) ([]string, error)

GetAllValidatorAddresses returns all validator addresses.

func (*PublicStakingService) GetAllValidatorInformation

func (s *PublicStakingService) GetAllValidatorInformation(
	ctx context.Context, page int,
) (interface{}, error)

GetAllValidatorInformation returns information about all validators.

func (*PublicStakingService) GetAllValidatorInformationByBlockNumber

func (s *PublicStakingService) GetAllValidatorInformationByBlockNumber(
	ctx context.Context, page int, blockNumber BlockNumber,
) (interface{}, error)

GetAllValidatorInformationByBlockNumber returns information about all validators. If page is -1, return all instead of `validatorsPageSize` elements.

func (*PublicStakingService) GetAvailableRedelegationBalance

func (s *PublicStakingService) GetAvailableRedelegationBalance(
	ctx context.Context, address string,
) (*big.Int, error)

GetAvailableRedelegationBalance returns the amount of locked undelegated tokens

func (*PublicStakingService) GetDelegationByDelegatorAndValidator

func (s *PublicStakingService) GetDelegationByDelegatorAndValidator(
	ctx context.Context, address string, validator string,
) (StructuredResponse, error)

GetDelegationByDelegatorAndValidator returns a delegation for delegator and validator.

func (*PublicStakingService) GetDelegationsByDelegator

func (s *PublicStakingService) GetDelegationsByDelegator(
	ctx context.Context, address string,
) ([]StructuredResponse, error)

GetDelegationsByDelegator returns list of delegations for a delegator address.

func (*PublicStakingService) GetDelegationsByDelegatorByBlockNumber

func (s *PublicStakingService) GetDelegationsByDelegatorByBlockNumber(
	ctx context.Context, aol AddressOrList, blockNumber BlockNumber,
) (interface{}, error)

GetDelegationsByDelegatorByBlockNumber returns list of delegations for a delegator address at given block number

func (*PublicStakingService) GetDelegationsByValidator

func (s *PublicStakingService) GetDelegationsByValidator(
	ctx context.Context, address string,
) ([]StructuredResponse, error)

GetDelegationsByValidator returns list of delegations for a validator address.

func (*PublicStakingService) GetElectedValidatorAddresses

func (s *PublicStakingService) GetElectedValidatorAddresses(
	ctx context.Context,
) ([]string, error)

GetElectedValidatorAddresses returns elected validator addresses.

func (*PublicStakingService) GetMedianRawStakeSnapshot

func (s *PublicStakingService) GetMedianRawStakeSnapshot(
	ctx context.Context,
) (StructuredResponse, error)

GetMedianRawStakeSnapshot returns the raw median stake, only meant to be called on beaconchain explorer node

func (*PublicStakingService) GetTotalStaking

func (s *PublicStakingService) GetTotalStaking(
	ctx context.Context,
) (*big.Int, error)

GetTotalStaking returns total staking by validators, only meant to be called on beaconchain explorer node

func (*PublicStakingService) GetValidatorInformation

func (s *PublicStakingService) GetValidatorInformation(
	ctx context.Context, address string,
) (StructuredResponse, error)

GetValidatorInformation returns information about a validator.

func (*PublicStakingService) GetValidatorInformationByBlockNumber

func (s *PublicStakingService) GetValidatorInformationByBlockNumber(
	ctx context.Context, address string, blockNumber BlockNumber,
) (StructuredResponse, error)

GetValidatorInformationByBlockNumber returns information about a validator.

func (*PublicStakingService) GetValidatorKeys

func (s *PublicStakingService) GetValidatorKeys(
	ctx context.Context, epoch int64,
) ([]string, error)

GetValidatorKeys returns list of bls public keys in the committee for a particular epoch.

func (*PublicStakingService) GetValidatorSelfDelegation

func (s *PublicStakingService) GetValidatorSelfDelegation(
	ctx context.Context, address string,
) (interface{}, error)

GetValidatorSelfDelegation returns validator stake.

func (*PublicStakingService) GetValidatorTotalDelegation

func (s *PublicStakingService) GetValidatorTotalDelegation(
	ctx context.Context, address string,
) (interface{}, error)

GetValidatorTotalDelegation returns total balance stacking for validator with delegation.

func (*PublicStakingService) GetValidators

func (s *PublicStakingService) GetValidators(
	ctx context.Context, epoch int64,
) (StructuredResponse, error)

GetValidators returns validators list for a particular epoch.

func (*PublicStakingService) GetValidatorsStakeByBlockNumber added in v0.1.8

func (s *PublicStakingService) GetValidatorsStakeByBlockNumber(
	ctx context.Context, blockNumber BlockNumber,
) (StructuredResponse, error)

GetValidatorsStakeByBlockNumber returns the stake per validator at the specified block

type PublicTracerService

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

PublicTracerService provides an API to access Harmony's staking services. It offers only methods that operate on public data that is freely available to anyone.

func (*PublicTracerService) TraceBlock

func (s *PublicTracerService) TraceBlock(ctx context.Context, blob []byte, config *hmy.TraceConfig) ([]*hmy.TxTraceResult, error)

TraceBlock returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PublicTracerService) TraceBlockByHash

func (s *PublicTracerService) TraceBlockByHash(ctx context.Context, hash common.Hash, config *hmy.TraceConfig) ([]*hmy.TxTraceResult, error)

TraceBlockByHash returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PublicTracerService) TraceBlockByNumber

func (s *PublicTracerService) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *hmy.TraceConfig) ([]*hmy.TxTraceResult, error)

TraceBlockByNumber returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*PublicTracerService) TraceCall

func (s *PublicTracerService) TraceCall(ctx context.Context, args CallArgs, blockNr rpc.BlockNumber, config *hmy.TraceConfig) (interface{}, error)

TraceCall lets you trace a given eth_call. It collects the structured logs created during the execution of EVM if the given transaction was added on top of the provided block and returns them as a JSON object. You can provide -2 as a block number to trace on top of the pending block. NOTE: Our version only supports block number as an input

func (*PublicTracerService) TraceChain

func (s *PublicTracerService) TraceChain(ctx context.Context, start, end rpc.BlockNumber, config *hmy.TraceConfig) (*rpc.Subscription, error)

TraceChain returns the structured logs created during the execution of EVM between two blocks (excluding start) and returns them as a JSON object.

func (*PublicTracerService) TraceTransaction

func (s *PublicTracerService) TraceTransaction(ctx context.Context, hash common.Hash, config *hmy.TraceConfig) (interface{}, error)

TraceTransaction returns the structured logs created during the execution of EVM and returns them as a JSON object.

type PublicTransactionService

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

PublicTransactionService provides an API to access Harmony's transaction service. It offers only methods that operate on public data that is freely available to anyone.

func (*PublicTransactionService) EstimateGas

func (s *PublicTransactionService) EstimateGas(
	ctx context.Context, args CallArgs, 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 (*PublicTransactionService) GetAccountNonce

func (s *PublicTransactionService) GetAccountNonce(
	ctx context.Context, address string, blockNumber BlockNumber,
) (uint64, error)

GetAccountNonce returns the nonce value of the given address for the given block number

func (*PublicTransactionService) GetBlockStakingTransactionCountByHash

func (s *PublicTransactionService) GetBlockStakingTransactionCountByHash(
	ctx context.Context, blockHash common.Hash,
) (interface{}, error)

GetBlockStakingTransactionCountByHash returns the number of staking transactions in the block with the given hash. Note that the return type is an interface to account for the different versions

func (*PublicTransactionService) GetBlockStakingTransactionCountByNumber

func (s *PublicTransactionService) GetBlockStakingTransactionCountByNumber(
	ctx context.Context, blockNumber BlockNumber,
) (interface{}, error)

GetBlockStakingTransactionCountByNumber returns the number of staking transactions in the block with the given block number. Note that the return type is an interface to account for the different versions

func (*PublicTransactionService) GetBlockTransactionCountByHash

func (s *PublicTransactionService) GetBlockTransactionCountByHash(
	ctx context.Context, blockHash common.Hash,
) (interface{}, error)

GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash. Note that the return type is an interface to account for the different versions

func (*PublicTransactionService) GetBlockTransactionCountByNumber

func (s *PublicTransactionService) GetBlockTransactionCountByNumber(
	ctx context.Context, blockNumber BlockNumber,
) (interface{}, error)

GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number. Note that the return type is an interface to account for the different versions

func (*PublicTransactionService) GetCXReceiptByHash

func (s *PublicTransactionService) GetCXReceiptByHash(
	ctx context.Context, hash common.Hash,
) (StructuredResponse, error)

GetCXReceiptByHash returns the transaction for the given hash

func (*PublicTransactionService) GetStakingTransactionByBlockHashAndIndex

func (s *PublicTransactionService) GetStakingTransactionByBlockHashAndIndex(
	ctx context.Context, blockHash common.Hash, index TransactionIndex,
) (StructuredResponse, error)

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

func (*PublicTransactionService) GetStakingTransactionByBlockNumberAndIndex

func (s *PublicTransactionService) GetStakingTransactionByBlockNumberAndIndex(
	ctx context.Context, blockNumber BlockNumber, index TransactionIndex,
) (StructuredResponse, error)

GetStakingTransactionByBlockNumberAndIndex returns the staking transaction for the given block number and index.

func (*PublicTransactionService) GetStakingTransactionByHash

func (s *PublicTransactionService) GetStakingTransactionByHash(
	ctx context.Context, hash common.Hash,
) (StructuredResponse, error)

GetStakingTransactionByHash returns the staking transaction for the given hash

func (*PublicTransactionService) GetStakingTransactionsCount

func (s *PublicTransactionService) GetStakingTransactionsCount(
	ctx context.Context, address, txType string,
) (count uint64, err error)

GetStakingTransactionsCount returns the number of staking transactions from genesis of input type ("SENT", "RECEIVED", "ALL")

func (*PublicTransactionService) GetStakingTransactionsHistory

func (s *PublicTransactionService) GetStakingTransactionsHistory(
	ctx context.Context, args TxHistoryArgs,
) (StructuredResponse, error)

GetStakingTransactionsHistory returns the list of transactions hashes that involve a particular address.

func (*PublicTransactionService) GetTransactionByBlockHashAndIndex

func (s *PublicTransactionService) GetTransactionByBlockHashAndIndex(
	ctx context.Context, blockHash common.Hash, index TransactionIndex,
) (StructuredResponse, error)

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

func (*PublicTransactionService) GetTransactionByBlockNumberAndIndex

func (s *PublicTransactionService) GetTransactionByBlockNumberAndIndex(
	ctx context.Context, blockNumber BlockNumber, index TransactionIndex,
) (StructuredResponse, error)

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

func (*PublicTransactionService) GetTransactionByHash

func (s *PublicTransactionService) GetTransactionByHash(
	ctx context.Context, hash common.Hash,
) (StructuredResponse, error)

GetTransactionByHash returns the plain transaction for the given hash

func (*PublicTransactionService) GetTransactionCount

func (s *PublicTransactionService) GetTransactionCount(
	ctx context.Context, addr string, blockNrOrHash rpc.BlockNumberOrHash,
) (response interface{}, err error)

GetTransactionCount returns the number of transactions the given address has sent for the given block number. Legacy for apiv1. For apiv2, please use getAccountNonce/getPoolNonce/getTransactionsCount/getStakingTransactionsCount apis for more granular transaction counts queries Note that the return type is an interface to account for the different versions

func (*PublicTransactionService) GetTransactionReceipt

func (s *PublicTransactionService) GetTransactionReceipt(
	ctx context.Context, hash common.Hash,
) (StructuredResponse, error)

GetTransactionReceipt returns the transaction receipt for the given transaction hash.

func (*PublicTransactionService) GetTransactionsCount

func (s *PublicTransactionService) GetTransactionsCount(
	ctx context.Context, address, txType string,
) (count uint64, err error)

GetTransactionsCount returns the number of regular transactions from genesis of input type ("SENT", "RECEIVED", "ALL")

func (*PublicTransactionService) GetTransactionsHistory

func (s *PublicTransactionService) GetTransactionsHistory(
	ctx context.Context, args TxHistoryArgs,
) (StructuredResponse, error)

GetTransactionsHistory returns the list of transactions hashes that involve a particular address.

func (*PublicTransactionService) ResendCx

func (s *PublicTransactionService) ResendCx(ctx context.Context, txID common.Hash) (bool, error)

ResendCx requests that the egress receipt for the given cross-shard transaction be sent to the destination shard for credit. This is used for unblocking a half-complete cross-shard transaction whose fund has been withdrawn already from the source shard but not credited yet in the destination account due to transient failures.

type PublicWeb3Service

type PublicWeb3Service struct{}

PublicWeb3Service offers web3 related RPC methods

func (*PublicWeb3Service) ClientVersion

func (s *PublicWeb3Service) ClientVersion(ctx context.Context) interface{}

ClientVersion - returns the current client version of the running node

type StakingNetworkInfo

type StakingNetworkInfo struct {
	TotalSupply       numeric.Dec `json:"total-supply"`
	CirculatingSupply numeric.Dec `json:"circulating-supply"`
	EpochLastBlock    uint64      `json:"epoch-last-block"`
	TotalStaking      *big.Int    `json:"total-staking"`
	MedianRawStake    numeric.Dec `json:"median-raw-stake"`
}

StakingNetworkInfo returns global staking info.

type StorageResult

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

type StructuredResponse

type StructuredResponse = map[string]interface{}

StructuredResponse type of RPCs

func NewStructuredResponse

func NewStructuredResponse(input interface{}) (StructuredResponse, error)

NewStructuredResponse creates a structured response from the given input

type TransactionIndex

type TransactionIndex uint64

TransactionIndex ..

func (*TransactionIndex) UnmarshalJSON

func (i *TransactionIndex) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON converts a hex string or integer to a Transaction index

type TxHistoryArgs

type TxHistoryArgs struct {
	Address   string `json:"address"`
	PageIndex uint32 `json:"pageIndex"`
	PageSize  uint32 `json:"pageSize"`
	FullTx    bool   `json:"fullTx"`
	TxType    string `json:"txType"`
	Order     string `json:"order"`
}

TxHistoryArgs is struct to include optional transaction formatting params.

func (*TxHistoryArgs) UnmarshalFromInterface

func (ta *TxHistoryArgs) UnmarshalFromInterface(blockArgs interface{}) error

UnmarshalFromInterface ..

type Undelegation

type Undelegation struct {
	Amount *big.Int
	Epoch  *big.Int
}

Undelegation represents one undelegation entry

type Version

type Version int

Version of the RPC

const (
	V1 Version = iota
	V2
	Eth
	Debug
	Trace
)

Version enum

func (Version) Namespace

func (n Version) Namespace() string

Namespace of the RPC version

Directories

Path Synopsis
Package filters implements an ethereum filtering system for block, transactions and log events.
Package filters implements an ethereum filtering system for block, transactions and log events.

Jump to

Keyboard shortcuts

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