Documentation
¶
Index ¶
- Constants
- func GetAddressKey(address string) string
- func GetBlockInfoKey(id int) string
- func GetBlockKey(id int) string
- func GetExplorerPort(nodePort string) string
- func GetTXKey(hash string) string
- type Address
- type Block
- type Data
- type HTTPError
- type Node
- type RefBlock
- type Service
- func (s *Service) APIs() []rpc.API
- func (s *Service) GetCirculatingSupply(w http.ResponseWriter, r *http.Request)
- func (s *Service) GetExplorerNodeCount(w http.ResponseWriter, r *http.Request)
- func (s *Service) GetExplorerShard(w http.ResponseWriter, r *http.Request)
- func (s *Service) GetTotalSupply(w http.ResponseWriter, r *http.Request)
- func (s *Service) Init(remove bool)
- func (s *Service) NotifyService(params map[string]interface{})
- func (s *Service) Run() *http.Server
- func (s *Service) SetMessageChan(messageChan chan *msg_pb.Message)
- func (s *Service) StartService()
- func (s *Service) StopService()
- type ServiceAPI
- type Shard
- type Storage
- func (storage *Storage) Dump(block *types.Block, height uint64)
- func (storage *Storage) GetDB() *ethdb.LDBDatabase
- func (storage *Storage) Init(ip, port string, remove bool)
- func (storage *Storage) UpdateAddress(batch ethdb.Batch, explorerTransaction *Transaction, tx *types.Transaction)
- func (storage *Storage) UpdateAddressStorage(batch ethdb.Batch, addr string, explorerTransaction *Transaction, ...)
- func (storage *Storage) UpdateTXStorage(batch ethdb.Batch, explorerTransaction *Transaction, tx *types.Transaction)
- type Transaction
- type Validator
Constants ¶
const ( BlockHeightKey = "bh" BlockInfoPrefix = "bi" BlockPrefix = "b" TXPrefix = "tx" AddressPrefix = "ad" )
Constants for storage.
const ( Received = "RECEIVED" Sent = "SENT" )
Tx types ...
Variables ¶
This section is empty.
Functions ¶
func GetExplorerPort ¶
GetExplorerPort returns the port serving explorer dashboard. This port is explorerPortDifference less than the node port.
Types ¶
type Address ¶
type Address struct {
ID string `json:"id"`
Balance *big.Int `json:"balance"`
TXs []*Transaction `json:"txs"`
}
Address ...
type Block ¶
type Block struct {
Height string `json:"height"`
ID string `json:"id"`
TXCount string `json:"txCount"`
Timestamp string `json:"timestamp"`
BlockTime int64 `json:"blockTime"`
MerkleRoot string `json:"merkleRoot"`
PrevBlock RefBlock `json:"prevBlock"`
Bytes string `json:"bytes"`
NextBlock RefBlock `json:"nextBlock"`
TXs []*Transaction `json:"txs"`
Signers []string `json:"signers"`
Epoch uint64 `json:"epoch"`
ExtraData string `json:"extra_data"`
}
Block ...
type Data ¶
type Data struct {
Blocks []*Block `json:"blocks"`
// Block Block `json:"block"`
Address Address `json:"Address"`
TX Transaction
}
Data ...
type Service ¶
type Service struct {
IP string
Port string
GetNodeIDs func() []libp2p_peer.ID
ShardID uint32
Storage *Storage
GetAccountBalance func(common.Address) (*big.Int, error)
// contains filtered or unexported fields
}
Service is the struct for explorer service.
func New ¶
func New(selfPeer *p2p.Peer, shardID uint32, GetNodeIDs func() []libp2p_peer.ID, GetAccountBalance func(common.Address) (*big.Int, error)) *Service
New returns explorer service.
func (*Service) GetCirculatingSupply ¶ added in v1.3.2
func (s *Service) GetCirculatingSupply(w http.ResponseWriter, r *http.Request)
GetCirculatingSupply serves /circulating-supply end-point.
func (*Service) GetExplorerNodeCount ¶
func (s *Service) GetExplorerNodeCount(w http.ResponseWriter, r *http.Request)
GetExplorerNodeCount serves /nodes end-point.
func (*Service) GetExplorerShard ¶
func (s *Service) GetExplorerShard(w http.ResponseWriter, r *http.Request)
GetExplorerShard serves /shard end-point.
func (*Service) GetTotalSupply ¶ added in v1.3.2
func (s *Service) GetTotalSupply(w http.ResponseWriter, r *http.Request)
GetTotalSupply serves /total-supply end-point.
func (*Service) NotifyService ¶
NotifyService notify service.
func (*Service) SetMessageChan ¶
SetMessageChan sets up message channel to service.
func (*Service) StartService ¶
func (s *Service) StartService()
StartService starts explorer service.
func (*Service) StopService ¶
func (s *Service) StopService()
StopService shutdowns explorer service.
type ServiceAPI ¶
type ServiceAPI struct {
Service *Service
}
ServiceAPI is rpc api.
func NewServiceAPI ¶
func NewServiceAPI(explorerService *Service) *ServiceAPI
NewServiceAPI returns explorer service api.
func (*ServiceAPI) GetExplorerNodeCount ¶
func (s *ServiceAPI) GetExplorerNodeCount(ctx context.Context) int
GetExplorerNodeCount rpc end-point.
func (*ServiceAPI) GetExplorerShard ¶
func (s *ServiceAPI) GetExplorerShard(ctx context.Context) *Shard
GetExplorerShard rpc end-point.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage dump the block info into leveldb.
func GetStorageInstance ¶
GetStorageInstance returns attack model by using singleton pattern.
func (*Storage) GetDB ¶
func (storage *Storage) GetDB() *ethdb.LDBDatabase
GetDB returns the LDBDatabase of the storage.
func (*Storage) UpdateAddress ¶
func (storage *Storage) UpdateAddress(batch ethdb.Batch, explorerTransaction *Transaction, tx *types.Transaction)
UpdateAddress ... TODO: deprecate this logic
func (*Storage) UpdateAddressStorage ¶
func (storage *Storage) UpdateAddressStorage(batch ethdb.Batch, addr string, explorerTransaction *Transaction, tx *types.Transaction)
UpdateAddressStorage updates specific addr Address. TODO: deprecate this logic
func (*Storage) UpdateTXStorage ¶
func (storage *Storage) UpdateTXStorage(batch ethdb.Batch, explorerTransaction *Transaction, tx *types.Transaction)
UpdateTXStorage ...
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
GetTransaction ...