Documentation ¶
Index ¶
- Constants
- func GetAddressKey(address string) string
- func GetBlockInfoKey(id int) string
- func GetBlockKey(id int) string
- func GetCommitteeKey(shardID uint32, epoch uint64) string
- func GetExplorerPort(nodePort string) string
- func GetTXKey(hash string) string
- type Address
- type Block
- type Committee
- type Data
- type HTTPError
- type Node
- type RefBlock
- type Service
- func (s *Service) APIs() []rpc.API
- func (s *Service) GetExplorerAddress(w http.ResponseWriter, r *http.Request)
- func (s *Service) GetExplorerBlocks(w http.ResponseWriter, r *http.Request)
- func (s *Service) GetExplorerCommittee(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) GetExplorerTransaction(w http.ResponseWriter, r *http.Request)
- func (s *Service) Init(remove bool)
- func (s *Service) NotifyService(params map[string]interface{})
- func (s *Service) ReadBlocksFromDB(from, to int) []*types.Block
- 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
- func (s *ServiceAPI) GetExplorerAddress(ctx context.Context, id, txView string, page, offset int, order string) (*Address, error)
- func (s *ServiceAPI) GetExplorerBlocks(ctx context.Context, from, to, page, offset int, withSigners bool, ...) ([]*Block, error)
- func (s *ServiceAPI) GetExplorerCommittee(ctx context.Context, shardID uint32, epoch uint64) (*Committee, error)
- func (s *ServiceAPI) GetExplorerNodeCount(ctx context.Context) int
- func (s *ServiceAPI) GetExplorerShard(ctx context.Context) *Shard
- func (s *ServiceAPI) GetExplorerTransaction(ctx context.Context, id string) (*Transaction, error)
- type Shard
- type Storage
- func (storage *Storage) Dump(block *types.Block, height uint64)
- func (storage *Storage) DumpCommittee(shardID uint32, epoch uint64, committee shard.Committee) error
- 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" CommitteePrefix = "cp" )
Constants for storage.
const ( Received = "RECEIVED" Sent = "SENT" )
Tx types ...
Variables ¶
This section is empty.
Functions ¶
func GetCommitteeKey ¶
GetCommitteeKey ...
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 Committee ¶
type Committee struct {
Validators []*Validator `json:"validators"`
}
Committee contains list of node validators of a particular shard and epoch.
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) GetExplorerAddress ¶
func (s *Service) GetExplorerAddress(w http.ResponseWriter, r *http.Request)
GetExplorerAddress serves /address end-point.
func (*Service) GetExplorerBlocks ¶
func (s *Service) GetExplorerBlocks(w http.ResponseWriter, r *http.Request)
GetExplorerBlocks serves end-point /blocks
func (*Service) GetExplorerCommittee ¶
func (s *Service) GetExplorerCommittee(w http.ResponseWriter, r *http.Request)
GetExplorerCommittee servers /comittee 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) GetExplorerTransaction ¶
func (s *Service) GetExplorerTransaction(w http.ResponseWriter, r *http.Request)
GetExplorerTransaction servers /tx end-point.
func (*Service) NotifyService ¶
NotifyService notify service.
func (*Service) ReadBlocksFromDB ¶
ReadBlocksFromDB returns a list of types.Block to server blocks end-point.
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) GetExplorerAddress ¶
func (s *ServiceAPI) GetExplorerAddress(ctx context.Context, id, txView string, page, offset int, order string) (*Address, error)
GetExplorerAddress rpc end-point.
func (*ServiceAPI) GetExplorerBlocks ¶
func (s *ServiceAPI) GetExplorerBlocks(ctx context.Context, from, to, page, offset int, withSigners bool, order string) ([]*Block, error)
GetExplorerBlocks rpc end-point.
func (*ServiceAPI) GetExplorerCommittee ¶
func (s *ServiceAPI) GetExplorerCommittee(ctx context.Context, shardID uint32, epoch uint64) (*Committee, error)
GetExplorerCommittee rpc end-point.
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.
func (*ServiceAPI) GetExplorerTransaction ¶
func (s *ServiceAPI) GetExplorerTransaction(ctx context.Context, id string) (*Transaction, error)
GetExplorerTransaction 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) DumpCommittee ¶
func (storage *Storage) DumpCommittee(shardID uint32, epoch uint64, committee shard.Committee) error
DumpCommittee commits validators for shardNum and epoch.
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 ...