explorer

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func NewExplorerProxy(url string) explorer.Explorer

NewExplorerProxy accepts an URL to the endpoint of the Explorer server and returns a proxy that implements the Explorer interface

Types

type BroadcastOutbound added in v0.4.4

type BroadcastOutbound func(ctx context.Context, chainID uint32, msg proto.Message) error

BroadcastOutbound sends a broadcast message to the whole network

type Config added in v0.4.4

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

Config represents the config to setup explorer

type GasStation added in v0.4.4

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

GasStation provide gas related api

type Neighbors added in v0.4.4

type Neighbors func(context.Context) ([]peerstore.PeerInfo, error)

Neighbors returns the neighbors' addresses

type NetworkInfo added in v0.4.4

type NetworkInfo func() peerstore.PeerInfo

NetworkInfo returns the self network information

type Option added in v0.4.4

type Option func(cfg *Config) error

Option is the option to override the explorer config

func WithBroadcastOutbound added in v0.4.4

func WithBroadcastOutbound(broadcastHandler BroadcastOutbound) Option

WithBroadcastOutbound is the option to broadcast msg outbound

func WithNeighbors added in v0.4.4

func WithNeighbors(neighborsHandler Neighbors) Option

WithNeighbors is the option to set the neighbors callback

func WithNetworkInfo added in v0.4.4

func WithNetworkInfo(selfHandler NetworkInfo) Option

WithNetworkInfo is the option to set the network information handler.

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,
	idx *indexservice.Server,
	opts ...Option,
) (*Server, error)

NewServer instantiates an explorer server

func (*Server) Explorer added in v0.4.0

func (s *Server) Explorer() explorer.Explorer

Explorer returns explorer interface.

func (*Server) Port added in v0.3.0

func (s *Server) Port() int

Port returns the actually binding port

func (*Server) SetMainChainProtocol added in v0.4.0

func (s *Server) SetMainChainProtocol(p *mainchain.Protocol)

SetMainChainProtocol sets the main-chain side multi-chain protocol

func (*Server) Start added in v0.3.0

func (s *Server) Start(_ context.Context) error

Start starts the explorer server

func (*Server) Stop added in v0.3.0

func (s *Server) Stop(ctx context.Context) error

Stop stops the explorer server

type Service

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

Service provide api for user to query blockchain data

func (*Service) CreateDeposit added in v0.4.0

func (exp *Service) CreateDeposit(req explorer.CreateDepositRequest) (res explorer.CreateDepositResponse, err error)

CreateDeposit deposits balance from main-chain to sub-chain

func (*Service) EstimateGasForSmartContract added in v0.4.4

func (exp *Service) EstimateGasForSmartContract(execution explorer.Execution) (int64, error)

EstimateGasForSmartContract suggest gas for smart contract

func (*Service) EstimateGasForTransfer added in v0.4.4

func (exp *Service) EstimateGasForTransfer(tsfJSON explorer.SendTransferRequest) (int64, error)

EstimateGasForTransfer estimate gas for transfer

func (*Service) EstimateGasForVote added in v0.4.4

func (exp *Service) EstimateGasForVote() (int64, error)

EstimateGasForVote suggest gas for vote

func (*Service) GetAddressBalance

func (exp *Service) GetAddressBalance(address string) (string, error)

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

func (exp *Service) GetBlockByID(blkID string) (explorer.Block, error)

GetBlockByID returns block by block id

func (*Service) GetBlockOrActionByHash added in v0.4.0

func (exp *Service) GetBlockOrActionByHash(hashStr string) (explorer.GetBlkOrActResponse, error)

GetBlockOrActionByHash get block or action by a hash

func (*Service) GetBlockchainHeight

func (exp *Service) GetBlockchainHeight() (int64, error)

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) GetCandidateMetricsByHeight added in v0.4.0

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 added in v0.4.0

func (exp *Service) GetCreateDeposit(createDepositID string) (explorer.CreateDeposit, error)

GetCreateDeposit gets create deposit by ID

func (*Service) GetCreateDepositsByAddress added in v0.4.0

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 added in v0.4.0

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) GetLastBlocksByRange

func (exp *Service) GetLastBlocksByRange(offset int64, limit int64) ([]explorer.Block, error)

GetLastBlocksByRange get block with height [offset-limit+1, offset]

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) GetReceiptByActionID added in v0.4.4

func (exp *Service) GetReceiptByActionID(id string) (explorer.Receipt, error)

GetReceiptByActionID gets receipt with corresponding action id

func (*Service) GetReceiptByExecutionID added in v0.3.0

func (exp *Service) GetReceiptByExecutionID(id string) (explorer.Receipt, error)

GetReceiptByExecutionID gets receipt with corresponding execution id Deprecated

func (*Service) GetSettleDeposit added in v0.4.0

func (exp *Service) GetSettleDeposit(settleDepositID string) (explorer.SettleDeposit, error)

GetSettleDeposit gets settle deposit by ID

func (*Service) GetSettleDepositsByAddress added in v0.4.0

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 added in v0.4.4

func (exp *Service) GetStateRootHash(blockHeight int64) (string, error)

GetStateRootHash gets the state root hash of a given block height

func (*Service) PutSubChainBlock added in v0.4.0

func (exp *Service) PutSubChainBlock(putBlockJSON explorer.PutSubChainBlockRequest) (resp explorer.PutSubChainBlockResponse, err error)

PutSubChainBlock put block merkel root on root chain.

func (*Service) ReadExecutionState added in v0.3.0

func (exp *Service) ReadExecutionState(execution explorer.Execution) (string, error)

ReadExecutionState reads the state in a contract address specified by the slot

func (*Service) SendAction added in v0.4.0

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 added in v0.3.0

func (exp *Service) SendSmartContract(execution explorer.Execution) (resp explorer.SendSmartContractResponse, err error)

SendSmartContract sends a smart contract

func (*Service) SendTransfer added in v0.3.0

func (exp *Service) SendTransfer(tsfJSON explorer.SendTransferRequest) (resp explorer.SendTransferResponse, err error)

SendTransfer sends a transfer

func (*Service) SendVote added in v0.3.0

func (exp *Service) SendVote(voteJSON explorer.SendVoteRequest) (resp explorer.SendVoteResponse, err error)

SendVote sends a vote

func (*Service) SetMainChainProtocol added in v0.4.0

func (exp *Service) SetMainChainProtocol(mainChain *mainchain.Protocol)

SetMainChainProtocol sets the main-chain side multi-chain protocol

func (*Service) SettleDeposit added in v0.4.0

func (exp *Service) SettleDeposit(req explorer.SettleDepositRequest) (res explorer.SettleDepositResponse, err error)

SettleDeposit settles deposit on sub-chain

func (*Service) SuggestGasPrice added in v0.4.4

func (exp *Service) SuggestGasPrice() (int64, error)

SuggestGasPrice suggest gas price

Directories

Path Synopsis
idl
explorer
Code generated by idl2go from JSON generated by Barrister v0.1.6
Code generated by idl2go from JSON generated by Barrister v0.1.6

Jump to

Keyboard shortcuts

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