Documentation ¶
Index ¶
- Variables
- func NewExplorerProxy(url string) explorer.Explorer
- type MockExplorer
- func (exp *MockExplorer) GetAddressBalance(address string) (int64, error)
- func (exp *MockExplorer) GetAddressDetails(address string) (explorer.AddressDetails, error)
- func (exp *MockExplorer) GetBlockByID(blkID string) (explorer.Block, error)
- func (exp *MockExplorer) GetBlockchainHeight() (int64, error)
- func (exp *MockExplorer) GetCandidateMetrics() (explorer.CandidateMetrics, error)
- func (exp *MockExplorer) GetCoinStatistic() (explorer.CoinStatistic, error)
- func (exp *MockExplorer) GetConsensusMetrics() (explorer.ConsensusMetrics, error)
- func (exp *MockExplorer) GetExecutionByID(executionID string) (explorer.Execution, error)
- func (exp *MockExplorer) GetExecutionsByAddress(address string, offset int64, limit int64) ([]explorer.Execution, error)
- func (exp *MockExplorer) GetExecutionsByBlockID(blkID string, offset int64, limit int64) ([]explorer.Execution, error)
- func (exp *MockExplorer) GetLastBlocksByRange(offset int64, limit int64) ([]explorer.Block, error)
- func (exp *MockExplorer) GetLastExecutionsByRange(startBlockHeight int64, offset int64, limit int64) ([]explorer.Execution, error)
- func (exp *MockExplorer) GetLastTransfersByRange(startBlockHeight int64, offset int64, limit int64, showCoinBase bool) ([]explorer.Transfer, error)
- func (exp *MockExplorer) GetLastVotesByRange(startBlockHeight int64, offset int64, limit int64) ([]explorer.Vote, error)
- func (exp *MockExplorer) GetPeers() (explorer.GetPeersResponse, error)
- func (exp *MockExplorer) GetReceiptByExecutionID(id string) (explorer.Receipt, error)
- func (exp *MockExplorer) GetTransferByID(transferID string) (explorer.Transfer, error)
- func (exp *MockExplorer) GetTransfersByAddress(address string, offset int64, limit int64) ([]explorer.Transfer, error)
- func (exp *MockExplorer) GetTransfersByBlockID(blockID string, offset int64, limit int64) ([]explorer.Transfer, error)
- func (exp *MockExplorer) GetUnconfirmedExecutionsByAddress(address string, offset int64, limit int64) ([]explorer.Execution, error)
- func (exp *MockExplorer) GetUnconfirmedTransfersByAddress(address string, offset int64, limit int64) ([]explorer.Transfer, error)
- func (exp *MockExplorer) GetUnconfirmedVotesByAddress(address string, offset int64, limit int64) ([]explorer.Vote, error)
- func (exp *MockExplorer) GetVoteByID(voteID string) (explorer.Vote, error)
- func (exp *MockExplorer) GetVotesByAddress(address string, offset int64, limit int64) ([]explorer.Vote, error)
- func (exp *MockExplorer) GetVotesByBlockID(blkID string, offset int64, limit int64) ([]explorer.Vote, error)
- func (exp *MockExplorer) ReadExecutionState(request explorer.Execution) (string, error)
- func (exp *MockExplorer) SendSmartContract(request explorer.Execution) (explorer.SendSmartContractResponse, error)
- func (exp *MockExplorer) SendTransfer(request explorer.SendTransferRequest) (explorer.SendTransferResponse, error)
- func (exp *MockExplorer) SendVote(request explorer.SendVoteRequest) (explorer.SendVoteResponse, error)
- type Server
- type Service
- func (exp *Service) GetAddressBalance(address string) (int64, error)
- func (exp *Service) GetAddressDetails(address string) (explorer.AddressDetails, error)
- func (exp *Service) GetBlockByID(blkID string) (explorer.Block, error)
- func (exp *Service) GetBlockchainHeight() (int64, error)
- func (exp *Service) GetCandidateMetrics() (explorer.CandidateMetrics, error)
- func (exp *Service) GetCoinStatistic() (explorer.CoinStatistic, error)
- func (exp *Service) GetConsensusMetrics() (explorer.ConsensusMetrics, 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) GetReceiptByExecutionID(id string) (explorer.Receipt, 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) ReadExecutionState(execution explorer.Execution) (string, error)
- func (exp *Service) SendSmartContract(execution explorer.Execution) (explorer.SendSmartContractResponse, error)
- func (exp *Service) SendTransfer(tsfJSON explorer.SendTransferRequest) (explorer.SendTransferResponse, error)
- func (exp *Service) SendVote(voteJSON explorer.SendVoteRequest) (explorer.SendVoteResponse, 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") )
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 MockExplorer ¶ added in v0.3.0
type MockExplorer struct { }
MockExplorer return an explorer for test purpose
func (*MockExplorer) GetAddressBalance ¶ added in v0.3.0
func (exp *MockExplorer) GetAddressBalance(address string) (int64, error)
GetAddressBalance returns the balance of an address
func (*MockExplorer) GetAddressDetails ¶ added in v0.3.0
func (exp *MockExplorer) GetAddressDetails(address string) (explorer.AddressDetails, error)
GetAddressDetails returns the properties of an address
func (*MockExplorer) GetBlockByID ¶ added in v0.3.0
func (exp *MockExplorer) GetBlockByID(blkID string) (explorer.Block, error)
GetBlockByID returns block by block id
func (*MockExplorer) GetBlockchainHeight ¶ added in v0.3.0
func (exp *MockExplorer) GetBlockchainHeight() (int64, error)
GetBlockchainHeight returns the blockchain height
func (*MockExplorer) GetCandidateMetrics ¶ added in v0.3.0
func (exp *MockExplorer) GetCandidateMetrics() (explorer.CandidateMetrics, error)
GetCandidateMetrics returns the fake delegates metrics
func (*MockExplorer) GetCoinStatistic ¶ added in v0.3.0
func (exp *MockExplorer) GetCoinStatistic() (explorer.CoinStatistic, error)
GetCoinStatistic returns stats in blockchain
func (*MockExplorer) GetConsensusMetrics ¶ added in v0.3.0
func (exp *MockExplorer) GetConsensusMetrics() (explorer.ConsensusMetrics, error)
GetConsensusMetrics returns the fake consensus metrics
func (*MockExplorer) GetExecutionByID ¶ added in v0.3.0
func (exp *MockExplorer) GetExecutionByID(executionID string) (explorer.Execution, error)
GetExecutionByID returns execution by execution id
func (*MockExplorer) GetExecutionsByAddress ¶ added in v0.3.0
func (exp *MockExplorer) GetExecutionsByAddress(address string, offset int64, limit int64) ([]explorer.Execution, error)
GetExecutionsByAddress returns all executions associate with an address
func (*MockExplorer) GetExecutionsByBlockID ¶ added in v0.3.0
func (exp *MockExplorer) GetExecutionsByBlockID(blkID string, offset int64, limit int64) ([]explorer.Execution, error)
GetExecutionsByBlockID returns executions in a block
func (*MockExplorer) GetLastBlocksByRange ¶ added in v0.3.0
GetLastBlocksByRange get block with height [offset-limit+1, offset]
func (*MockExplorer) GetLastExecutionsByRange ¶ added in v0.3.0
func (exp *MockExplorer) GetLastExecutionsByRange(startBlockHeight int64, offset int64, limit int64) ([]explorer.Execution, error)
GetLastExecutionsByRange return executions in [-(offset+limit-1), -offset] from block with height startBlockHeight
func (*MockExplorer) GetLastTransfersByRange ¶ added in v0.3.0
func (exp *MockExplorer) GetLastTransfersByRange(startBlockHeight int64, offset int64, limit int64, showCoinBase bool) ([]explorer.Transfer, error)
GetLastTransfersByRange return transfers in [-(offset+limit-1), -offset] from block with height startBlockHeight
func (*MockExplorer) GetLastVotesByRange ¶ added in v0.3.0
func (exp *MockExplorer) GetLastVotesByRange(startBlockHeight int64, offset int64, limit int64) ([]explorer.Vote, error)
GetLastVotesByRange return votes in [-(offset+limit-1), -offset] from block with height startBlockHeight
func (*MockExplorer) GetPeers ¶ added in v0.3.0
func (exp *MockExplorer) GetPeers() (explorer.GetPeersResponse, error)
GetPeers returns a empty GetPeersResponse.
func (*MockExplorer) GetReceiptByExecutionID ¶ added in v0.3.0
func (exp *MockExplorer) GetReceiptByExecutionID(id string) (explorer.Receipt, error)
GetReceiptByExecutionID gets receipt with corresponding execution id
func (*MockExplorer) GetTransferByID ¶ added in v0.3.0
func (exp *MockExplorer) GetTransferByID(transferID string) (explorer.Transfer, error)
GetTransferByID returns transfer by transfer id
func (*MockExplorer) GetTransfersByAddress ¶ added in v0.3.0
func (exp *MockExplorer) GetTransfersByAddress(address string, offset int64, limit int64) ([]explorer.Transfer, error)
GetTransfersByAddress returns all transfers associate with an address
func (*MockExplorer) GetTransfersByBlockID ¶ added in v0.3.0
func (exp *MockExplorer) GetTransfersByBlockID(blockID string, offset int64, limit int64) ([]explorer.Transfer, error)
GetTransfersByBlockID returns transfers in a block
func (*MockExplorer) GetUnconfirmedExecutionsByAddress ¶ added in v0.3.0
func (exp *MockExplorer) GetUnconfirmedExecutionsByAddress(address string, offset int64, limit int64) ([]explorer.Execution, error)
GetUnconfirmedExecutionsByAddress returns all unconfirmed executions in actpool associated with an address
func (*MockExplorer) GetUnconfirmedTransfersByAddress ¶ added in v0.3.0
func (exp *MockExplorer) GetUnconfirmedTransfersByAddress(address string, offset int64, limit int64) ([]explorer.Transfer, error)
GetUnconfirmedTransfersByAddress returns all unconfirmed transfers in actpool associated with an address
func (*MockExplorer) GetUnconfirmedVotesByAddress ¶ added in v0.3.0
func (exp *MockExplorer) GetUnconfirmedVotesByAddress(address string, offset int64, limit int64) ([]explorer.Vote, error)
GetUnconfirmedVotesByAddress returns all unconfirmed votes in actpool associated with an address
func (*MockExplorer) GetVoteByID ¶ added in v0.3.0
func (exp *MockExplorer) GetVoteByID(voteID string) (explorer.Vote, error)
GetVoteByID returns vote by vote id
func (*MockExplorer) GetVotesByAddress ¶ added in v0.3.0
func (exp *MockExplorer) GetVotesByAddress(address string, offset int64, limit int64) ([]explorer.Vote, error)
GetVotesByAddress returns all votes associate with an address
func (*MockExplorer) GetVotesByBlockID ¶ added in v0.3.0
func (exp *MockExplorer) GetVotesByBlockID(blkID string, offset int64, limit int64) ([]explorer.Vote, error)
GetVotesByBlockID returns votes in a block
func (*MockExplorer) ReadExecutionState ¶ added in v0.3.0
func (exp *MockExplorer) ReadExecutionState(request explorer.Execution) (string, error)
ReadExecutionState sends a smart contract
func (*MockExplorer) SendSmartContract ¶ added in v0.3.0
func (exp *MockExplorer) SendSmartContract(request explorer.Execution) (explorer.SendSmartContractResponse, error)
SendSmartContract sends a smart contract
func (*MockExplorer) SendTransfer ¶ added in v0.3.0
func (exp *MockExplorer) SendTransfer(request explorer.SendTransferRequest) (explorer.SendTransferResponse, error)
SendTransfer sends a fake transfer
func (*MockExplorer) SendVote ¶ added in v0.3.0
func (exp *MockExplorer) SendVote(request explorer.SendVoteRequest) (explorer.SendVoteResponse, error)
SendVote sends a fake vote
type Server ¶ added in v0.3.0
type Server struct {
// contains filtered or unexported fields
}
Server is the container of the explorer service
func NewServer ¶ added in v0.3.0
func NewServer( cfg config.Explorer, chain blockchain.Blockchain, consensus consensus.Consensus, dispatcher dispatcher.Dispatcher, actPool actpool.ActPool, p2p network.Overlay, ) *Server
NewServer instantiates an explorer server
func NewTestSever ¶ added in v0.3.0
NewTestSever instantiates an explorer server with mock handler
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provide api for user to query blockchain data
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) GetBlockchainHeight ¶
GetBlockchainHeight returns the current blockchain tip height
func (*Service) GetCandidateMetrics ¶ added in v0.3.0
func (exp *Service) GetCandidateMetrics() (explorer.CandidateMetrics, error)
GetCandidateMetrics returns the latest delegates metrics
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) GetExecutionByID ¶ added in v0.3.0
GetExecutionByID returns execution by execution id
func (*Service) GetExecutionsByAddress ¶ added in v0.3.0
func (exp *Service) GetExecutionsByAddress(address string, offset int64, limit int64) ([]explorer.Execution, error)
GetExecutionsByAddress returns all executions associated with an address
func (*Service) GetExecutionsByBlockID ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (exp *Service) GetPeers() (explorer.GetPeersResponse, error)
GetPeers return a list of node peers and itself's network addsress info.
func (*Service) GetReceiptByExecutionID ¶ added in v0.3.0
GetReceiptByExecutionID gets receipt with corresponding execution id
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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
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) ReadExecutionState ¶ added in v0.3.0
ReadExecutionState reads the state in a contract address specified by the slot
func (*Service) SendSmartContract ¶ added in v0.3.0
func (exp *Service) SendSmartContract(execution explorer.Execution) (explorer.SendSmartContractResponse, error)
SendSmartContract sends a smart contract
func (*Service) SendTransfer ¶ added in v0.3.0
func (exp *Service) SendTransfer(tsfJSON explorer.SendTransferRequest) (explorer.SendTransferResponse, error)
SendTransfer sends a transfer
func (*Service) SendVote ¶ added in v0.3.0
func (exp *Service) SendVote(voteJSON explorer.SendVoteRequest) (explorer.SendVoteResponse, error)
SendVote sends a vote