Documentation ¶
Index ¶
- Variables
- func NewExplorerProxy(url string) explorer.Explorer
- type BroadcastOutbound
- type Config
- type GasStation
- type Neighbors
- type NetworkInfo
- type Option
- type Server
- type Service
- func (exp *Service) CreateDeposit(req explorer.CreateDepositRequest) (res explorer.CreateDepositResponse, err error)
- func (exp *Service) EstimateGasForSmartContract(execution explorer.Execution) (int64, error)
- func (exp *Service) EstimateGasForTransfer(tsfJSON explorer.SendTransferRequest) (int64, error)
- func (exp *Service) EstimateGasForVote() (int64, error)
- func (exp *Service) GetAddressBalance(address string) (string, error)
- func (exp *Service) GetAddressDetails(address string) (explorer.AddressDetails, error)
- func (exp *Service) GetBlockByID(blkID string) (explorer.Block, error)
- func (exp *Service) GetBlockOrActionByHash(hashStr string) (explorer.GetBlkOrActResponse, error)
- func (exp *Service) GetBlockchainHeight() (int64, error)
- func (exp *Service) GetCandidateMetrics() (explorer.CandidateMetrics, error)
- func (exp *Service) GetCandidateMetricsByHeight(h int64) (explorer.CandidateMetrics, error)
- func (exp *Service) GetCoinStatistic() (explorer.CoinStatistic, error)
- func (exp *Service) GetConsensusMetrics() (explorer.ConsensusMetrics, error)
- func (exp *Service) GetCreateDeposit(createDepositID string) (explorer.CreateDeposit, error)
- func (exp *Service) GetCreateDepositsByAddress(address string, offset int64, limit int64) ([]explorer.CreateDeposit, error)
- func (exp *Service) GetDeposits(subChainID int64, offset int64, limit int64) ([]explorer.Deposit, error)
- func (exp *Service) GetExecutionByID(executionID string) (explorer.Execution, error)
- func (exp *Service) GetExecutionsByAddress(address string, offset int64, limit int64) ([]explorer.Execution, error)
- func (exp *Service) GetExecutionsByBlockID(blkID string, offset int64, limit int64) ([]explorer.Execution, error)
- func (exp *Service) GetLastBlocksByRange(offset int64, limit int64) ([]explorer.Block, error)
- func (exp *Service) GetLastExecutionsByRange(startBlockHeight int64, offset int64, limit int64) ([]explorer.Execution, error)
- func (exp *Service) GetLastTransfersByRange(startBlockHeight int64, offset int64, limit int64, showCoinBase bool) ([]explorer.Transfer, error)
- func (exp *Service) GetLastVotesByRange(startBlockHeight int64, offset int64, limit int64) ([]explorer.Vote, error)
- func (exp *Service) GetPeers() (explorer.GetPeersResponse, error)
- func (exp *Service) GetReceiptByActionID(id string) (explorer.Receipt, error)
- func (exp *Service) GetReceiptByExecutionID(id string) (explorer.Receipt, error)
- func (exp *Service) GetSettleDeposit(settleDepositID string) (explorer.SettleDeposit, error)
- func (exp *Service) GetSettleDepositsByAddress(address string, offset int64, limit int64) ([]explorer.SettleDeposit, error)
- func (exp *Service) GetStateRootHash(blockHeight int64) (string, error)
- func (exp *Service) GetTransferByID(transferID string) (explorer.Transfer, error)
- func (exp *Service) GetTransfersByAddress(address string, offset int64, limit int64) ([]explorer.Transfer, error)
- func (exp *Service) GetTransfersByBlockID(blkID string, offset int64, limit int64) ([]explorer.Transfer, error)
- func (exp *Service) GetUnconfirmedExecutionsByAddress(address string, offset int64, limit int64) ([]explorer.Execution, error)
- func (exp *Service) GetUnconfirmedTransfersByAddress(address string, offset int64, limit int64) ([]explorer.Transfer, error)
- func (exp *Service) GetUnconfirmedVotesByAddress(address string, offset int64, limit int64) ([]explorer.Vote, error)
- func (exp *Service) GetVoteByID(voteID string) (explorer.Vote, error)
- func (exp *Service) GetVotesByAddress(address string, offset int64, limit int64) ([]explorer.Vote, error)
- func (exp *Service) GetVotesByBlockID(blkID string, offset int64, limit int64) ([]explorer.Vote, error)
- func (exp *Service) PutSubChainBlock(putBlockJSON explorer.PutSubChainBlockRequest) (resp explorer.PutSubChainBlockResponse, err error)
- func (exp *Service) ReadExecutionState(execution explorer.Execution) (string, error)
- func (exp *Service) SendAction(req explorer.SendActionRequest) (resp explorer.SendActionResponse, err error)
- func (exp *Service) SendSmartContract(execution explorer.Execution) (resp explorer.SendSmartContractResponse, err error)
- func (exp *Service) SendTransfer(tsfJSON explorer.SendTransferRequest) (resp explorer.SendTransferResponse, err error)
- func (exp *Service) SendVote(voteJSON explorer.SendVoteRequest) (resp explorer.SendVoteResponse, err error)
- func (exp *Service) SetMainChainProtocol(mainChain *mainchain.Protocol)
- func (exp *Service) SettleDeposit(req explorer.SettleDepositRequest) (res explorer.SettleDepositResponse, err error)
- func (exp *Service) SuggestGasPrice() (int64, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInternalServer indicates the internal server error ErrInternalServer = errors.New("internal server error") // ErrTransfer indicates the error of transfer ErrTransfer = errors.New("invalid transfer") // ErrVote indicates the error of vote ErrVote = errors.New("invalid vote") // ErrExecution indicates the error of execution ErrExecution = errors.New("invalid execution") // ErrReceipt indicates the error of receipt ErrReceipt = errors.New("invalid receipt") // ErrAction indicates the error of action ErrAction = errors.New("invalid action") )
Functions ¶
func NewExplorerProxy ¶
NewExplorerProxy accepts an URL to the endpoint of the Explorer server and returns a proxy that implements the Explorer interface
Types ¶
type BroadcastOutbound ¶
BroadcastOutbound sends a broadcast message to the whole network
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents the config to setup explorer
type GasStation ¶
type GasStation struct {
// contains filtered or unexported fields
}
GasStation provide gas related api
type NetworkInfo ¶
NetworkInfo returns the self network information
type Option ¶
Option is the option to override the explorer config
func WithBroadcastOutbound ¶
func WithBroadcastOutbound(broadcastHandler BroadcastOutbound) Option
WithBroadcastOutbound is the option to broadcast msg outbound
func WithNeighbors ¶
WithNeighbors is the option to set the neighbors callback
func WithNetworkInfo ¶
func WithNetworkInfo(selfHandler NetworkInfo) Option
WithNetworkInfo is the option to set the network information handler.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the container of the explorer service
func NewServer ¶
func NewServer( cfg config.Explorer, chain blockchain.Blockchain, consensus consensus.Consensus, dispatcher dispatcher.Dispatcher, actPool actpool.ActPool, idx *indexservice.Server, opts ...Option, ) (*Server, error)
NewServer instantiates an explorer server
func (*Server) SetMainChainProtocol ¶
SetMainChainProtocol sets the main-chain side multi-chain protocol
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provide api for user to query blockchain data
func (*Service) CreateDeposit ¶
func (exp *Service) CreateDeposit(req explorer.CreateDepositRequest) (res explorer.CreateDepositResponse, err error)
CreateDeposit deposits balance from main-chain to sub-chain
func (*Service) EstimateGasForSmartContract ¶
EstimateGasForSmartContract suggest gas for smart contract
func (*Service) EstimateGasForTransfer ¶
func (exp *Service) EstimateGasForTransfer(tsfJSON explorer.SendTransferRequest) (int64, error)
EstimateGasForTransfer estimate gas for transfer
func (*Service) EstimateGasForVote ¶
EstimateGasForVote suggest gas for vote
func (*Service) GetAddressBalance ¶
GetAddressBalance returns the balance of an address
func (*Service) GetAddressDetails ¶
func (exp *Service) GetAddressDetails(address string) (explorer.AddressDetails, error)
GetAddressDetails returns the properties of an address
func (*Service) GetBlockByID ¶
GetBlockByID returns block by block id
func (*Service) GetBlockOrActionByHash ¶
func (exp *Service) GetBlockOrActionByHash(hashStr string) (explorer.GetBlkOrActResponse, error)
GetBlockOrActionByHash get block or action by a hash
func (*Service) GetBlockchainHeight ¶
GetBlockchainHeight returns the current blockchain tip height
func (*Service) GetCandidateMetrics ¶
func (exp *Service) GetCandidateMetrics() (explorer.CandidateMetrics, error)
GetCandidateMetrics returns the latest delegates metrics
func (*Service) GetCandidateMetricsByHeight ¶
func (exp *Service) GetCandidateMetricsByHeight(h int64) (explorer.CandidateMetrics, error)
GetCandidateMetricsByHeight returns the candidates metrics for given height.
func (*Service) GetCoinStatistic ¶
func (exp *Service) GetCoinStatistic() (explorer.CoinStatistic, error)
GetCoinStatistic returns stats in blockchain
func (*Service) GetConsensusMetrics ¶
func (exp *Service) GetConsensusMetrics() (explorer.ConsensusMetrics, error)
GetConsensusMetrics returns the latest consensus metrics
func (*Service) GetCreateDeposit ¶
func (exp *Service) GetCreateDeposit(createDepositID string) (explorer.CreateDeposit, error)
GetCreateDeposit gets create deposit by ID
func (*Service) GetCreateDepositsByAddress ¶
func (exp *Service) GetCreateDepositsByAddress( address string, offset int64, limit int64, ) ([]explorer.CreateDeposit, error)
GetCreateDepositsByAddress gets the relevant create deposits of an address
func (*Service) GetDeposits ¶
func (exp *Service) GetDeposits(subChainID int64, offset int64, limit int64) ([]explorer.Deposit, error)
GetDeposits returns the deposits of a sub-chain in the given range in descending order by the index
func (*Service) GetExecutionByID ¶
GetExecutionByID returns execution by execution id
func (*Service) GetExecutionsByAddress ¶
func (exp *Service) GetExecutionsByAddress(address string, offset int64, limit int64) ([]explorer.Execution, error)
GetExecutionsByAddress returns all executions associated with an address
func (*Service) GetExecutionsByBlockID ¶
func (exp *Service) GetExecutionsByBlockID(blkID string, offset int64, limit int64) ([]explorer.Execution, error)
GetExecutionsByBlockID returns executions in a block
func (*Service) GetLastBlocksByRange ¶
GetLastBlocksByRange get block with height [offset-limit+1, offset]
func (*Service) GetLastExecutionsByRange ¶
func (exp *Service) GetLastExecutionsByRange(startBlockHeight int64, offset int64, limit int64) ([]explorer.Execution, error)
GetLastExecutionsByRange returns executions in [-(offset+limit-1), -offset] from block with height startBlockHeight
func (*Service) GetLastTransfersByRange ¶
func (exp *Service) GetLastTransfersByRange(startBlockHeight int64, offset int64, limit int64, showCoinBase bool) ([]explorer.Transfer, error)
GetLastTransfersByRange returns transfers in [-(offset+limit-1), -offset] from block with height startBlockHeight
func (*Service) GetLastVotesByRange ¶
func (exp *Service) GetLastVotesByRange(startBlockHeight int64, offset int64, limit int64) ([]explorer.Vote, error)
GetLastVotesByRange returns votes in [-(offset+limit-1), -offset] from block with height startBlockHeight
func (*Service) GetPeers ¶
func (exp *Service) GetPeers() (explorer.GetPeersResponse, error)
GetPeers return a list of node peers and itself's network addsress info.
func (*Service) GetReceiptByActionID ¶
GetReceiptByActionID gets receipt with corresponding action id
func (*Service) GetReceiptByExecutionID ¶
GetReceiptByExecutionID gets receipt with corresponding execution id Deprecated
func (*Service) GetSettleDeposit ¶
func (exp *Service) GetSettleDeposit(settleDepositID string) (explorer.SettleDeposit, error)
GetSettleDeposit gets settle deposit by ID
func (*Service) GetSettleDepositsByAddress ¶
func (exp *Service) GetSettleDepositsByAddress( address string, offset int64, limit int64, ) ([]explorer.SettleDeposit, error)
GetSettleDepositsByAddress gets the relevant settle deposits of an address
func (*Service) GetStateRootHash ¶
GetStateRootHash gets the state root hash of a given block height
func (*Service) GetTransferByID ¶
GetTransferByID returns transfer by transfer id
func (*Service) GetTransfersByAddress ¶
func (exp *Service) GetTransfersByAddress(address string, offset int64, limit int64) ([]explorer.Transfer, error)
GetTransfersByAddress returns all transfers associated with an address
func (*Service) GetTransfersByBlockID ¶
func (exp *Service) GetTransfersByBlockID(blkID string, offset int64, limit int64) ([]explorer.Transfer, error)
GetTransfersByBlockID returns transfers in a block
func (*Service) GetUnconfirmedExecutionsByAddress ¶
func (exp *Service) GetUnconfirmedExecutionsByAddress(address string, offset int64, limit int64) ([]explorer.Execution, error)
GetUnconfirmedExecutionsByAddress returns all unconfirmed executions in actpool associated with an address
func (*Service) GetUnconfirmedTransfersByAddress ¶
func (exp *Service) GetUnconfirmedTransfersByAddress(address string, offset int64, limit int64) ([]explorer.Transfer, error)
GetUnconfirmedTransfersByAddress returns all unconfirmed transfers in actpool associated with an address
func (*Service) GetUnconfirmedVotesByAddress ¶
func (exp *Service) GetUnconfirmedVotesByAddress(address string, offset int64, limit int64) ([]explorer.Vote, error)
GetUnconfirmedVotesByAddress returns all unconfirmed votes in actpool associated with an address
func (*Service) GetVoteByID ¶
GetVoteByID returns vote by vote id
func (*Service) GetVotesByAddress ¶
func (exp *Service) GetVotesByAddress(address string, offset int64, limit int64) ([]explorer.Vote, error)
GetVotesByAddress returns all votes associated with an address
func (*Service) GetVotesByBlockID ¶
func (exp *Service) GetVotesByBlockID(blkID string, offset int64, limit int64) ([]explorer.Vote, error)
GetVotesByBlockID returns votes in a block
func (*Service) PutSubChainBlock ¶
func (exp *Service) PutSubChainBlock(putBlockJSON explorer.PutSubChainBlockRequest) (resp explorer.PutSubChainBlockResponse, err error)
PutSubChainBlock put block merkel root on root chain.
func (*Service) ReadExecutionState ¶
ReadExecutionState reads the state in a contract address specified by the slot
func (*Service) SendAction ¶
func (exp *Service) SendAction(req explorer.SendActionRequest) (resp explorer.SendActionResponse, err error)
SendAction is the API to send an action to blockchain.
func (*Service) SendSmartContract ¶
func (exp *Service) SendSmartContract(execution explorer.Execution) (resp explorer.SendSmartContractResponse, err error)
SendSmartContract sends a smart contract
func (*Service) SendTransfer ¶
func (exp *Service) SendTransfer(tsfJSON explorer.SendTransferRequest) (resp explorer.SendTransferResponse, err error)
SendTransfer sends a transfer
func (*Service) SendVote ¶
func (exp *Service) SendVote(voteJSON explorer.SendVoteRequest) (resp explorer.SendVoteResponse, err error)
SendVote sends a vote
func (*Service) SetMainChainProtocol ¶
SetMainChainProtocol sets the main-chain side multi-chain protocol
func (*Service) SettleDeposit ¶
func (exp *Service) SettleDeposit(req explorer.SettleDepositRequest) (res explorer.SettleDepositResponse, err error)
SettleDeposit settles deposit on sub-chain
func (*Service) SuggestGasPrice ¶
SuggestGasPrice suggest gas price