explorer

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: LGPL-3.0 Imports: 42 Imported by: 0

Documentation

Overview

TODO: refactor this whole module to v0 and v1

Index

Constants

View Source
const (
	LegAddressPrefix = "ad_"
	CheckpointPrefix = "dc"
	TracePrefix      = "tr_"
)
View Source
const (
	LegReceived = "RECEIVED"
	LegSent     = "SENT"
)

Tx types ...

Variables

View Source
var ErrExplorerNotReady = errors.New("explorer db not ready")

ErrExplorerNotReady is the error when querying explorer db data when explorer db is doing migration and unavailable

Functions

func GetCheckpointKey

func GetCheckpointKey(blockNum *big.Int) []byte

Common schema GetCheckpointKey ...

func GetExplorerPort

func GetExplorerPort(nodePort string) string

GetExplorerPort returns the port serving explorer dashboard. This port is explorerPortDifference less than the node port.

func LegGetAddressKey

func LegGetAddressKey(address oneAddress) []byte

LegGetAddressKey ...

Types

type Address

type Address struct {
	ID         string       `json:"id"`
	Balance    *big.Int     `json:"balance"` // Deprecated
	TXs        LegTxRecords `json:"txs"`
	StakingTXs LegTxRecords `json:"staking_txs"`
}

Address ...

type Data

type Data struct {
	Addresses []string `json:"Addresses"`
}

Data ...

type HTTPError

type HTTPError struct {
	Code int
	Msg  string
}

HTTPError is an HTTP error.

type HeightResponse

type HeightResponse struct {
	S0 uint64 `json:"0,omitempty"`
	S1 uint64 `json:"1,omitempty"`
	S2 uint64 `json:"2,omitempty"`
	S3 uint64 `json:"3,omitempty"`
}

type InaccessibleAddressInfo

type InaccessibleAddressInfo struct {
	EthAddress ethCommon.Address `json:"eth-address"`
	Address    string            `json:"address"`
	Balance    numeric.Dec       `json:"balance"`
	Nonce      uint64            `json:"nonce"`
}

InaccessibleAddressInfo ..

type LegTxRecord

type LegTxRecord struct {
	Hash      string
	Type      string
	Timestamp string
}

LegTxRecord ...

type LegTxRecords

type LegTxRecords []*LegTxRecord

LegTxRecords ...

type Service

type Service struct {
	IP   string
	Port string
	// contains filtered or unexported fields
}

Service is the struct for explorer service.

func New

func New(selfPeer *p2p.Peer, bc *core.BlockChain, backend hmy.NodeAPI) *Service

New returns explorer service.

func (*Service) DumpCatchupBlock

func (s *Service) DumpCatchupBlock(b *types.Block)

DumpCatchupBlock instruct the explorer storage to dump a catch up block in explorer DB

func (*Service) DumpNewBlock

func (s *Service) DumpNewBlock(b *types.Block)

DumpNewBlock instruct the explorer storage to dump block data in explorer DB

func (*Service) DumpTraceResult

func (s *Service) DumpTraceResult(data *tracers.TraceBlockStorage)

DumpTraceResult instruct the explorer storage to trace data in explorer DB

func (*Service) GetAddresses

func (s *Service) GetAddresses(w http.ResponseWriter, r *http.Request)

GetAddresses serves end-point /addresses, returns size of addresses from address with prefix.

func (*Service) GetCirculatingSupply

func (s *Service) GetCirculatingSupply(w http.ResponseWriter, r *http.Request)

GetCirculatingSupply serves /circulating-supply end-point. Note that known InaccessibleAddresses have their funds removed from the supply for this endpoint.

func (*Service) GetHeight

func (s *Service) GetHeight(w http.ResponseWriter, r *http.Request)

GetHeight returns heights of current and beacon chains if needed.

func (*Service) GetInaccessibleAddressInfo

func (s *Service) GetInaccessibleAddressInfo(w http.ResponseWriter, r *http.Request)

GetInaccessibleAddressInfo serves /burn-addresses end-point.

func (*Service) GetNodeSync

func (s *Service) GetNodeSync(w http.ResponseWriter, r *http.Request)

GetNodeSync returns status code Teapot 418 if node is not in sync

func (*Service) GetNormalTxHashesByAccount

func (s *Service) GetNormalTxHashesByAccount(address string) ([]ethCommon.Hash, []TxType, error)

GetNormalTxHashesByAccount get the normal transaction hashes by account

func (*Service) GetStakingTxHashesByAccount

func (s *Service) GetStakingTxHashesByAccount(address string) ([]ethCommon.Hash, []TxType, error)

GetStakingTxHashesByAccount get the staking transaction hashes by account

func (*Service) GetTotalSupply

func (s *Service) GetTotalSupply(w http.ResponseWriter, r *http.Request)

GetTotalSupply serves /total-supply end-point. Note that known InaccessibleAddresses have their funds removed from the supply for this endpoint.

func (*Service) GetTraceResultByHash

func (s *Service) GetTraceResultByHash(hash ethCommon.Hash) (json.RawMessage, error)

func (*Service) Init

func (s *Service) Init()

Init is to initialize for ExplorerService.

func (*Service) IsAvailable

func (s *Service) IsAvailable() bool

IsAvailable return whether the explorer db is available for now.

func (*Service) NotifyService

func (s *Service) NotifyService(params map[string]interface{})

NotifyService notify service.

func (*Service) Run

func (s *Service) Run() *http.Server

Run is to run serving explorer.

func (*Service) SetMessageChan

func (s *Service) SetMessageChan(messageChan chan *msg_pb.Message)

SetMessageChan sets up message channel to service.

func (*Service) Start

func (s *Service) Start() error

Start starts explorer service.

func (*Service) Stop

func (s *Service) Stop() error

Stop shutdowns explorer service.

type StakingTransaction

type StakingTransaction struct {
	Transaction
}

StakingTransaction ...

func GetStakingTransaction

func GetStakingTransaction(tx *staking.StakingTransaction, addressBlock *types.Block) (*StakingTransaction, error)

GetStakingTransaction ...

type Transaction

type Transaction struct {
	ID        string   `json:"id"`
	Timestamp string   `json:"timestamp"`
	From      string   `json:"from"`
	To        string   `json:"to"`
	Value     *big.Int `json:"value"`
	Bytes     string   `json:"bytes"`
	Data      string   `json:"data"`
	GasFee    *big.Int `json:"gasFee"`
	FromShard uint32   `json:"fromShard"`
	ToShard   uint32   `json:"toShard"`
	Type      string   `json:"type"`
}

Transaction ...

func GetTransaction

func GetTransaction(tx *types.Transaction, addressBlock *types.Block) (*Transaction, error)

GetTransaction ...

type TxRecord

type TxRecord struct {
	Hash      common.Hash
	Timestamp time.Time
}

TxRecord is the data structure stored in explorer db for the a Transaction record

func (*TxRecord) DecodeRLP

func (tx *TxRecord) DecodeRLP(st *rlp.Stream) error

func (*TxRecord) EncodeRLP

func (tx *TxRecord) EncodeRLP(w io.Writer) error

type TxType

type TxType byte

TxType is the transaction type. Currently on txSent and txReceived. TODO: add staking to this type logic handle.

func (TxType) String

func (t TxType) String() string

Jump to

Keyboard shortcuts

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