explorer

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockHeightKey  = "bh"
	BlockInfoPrefix = "bi"
	BlockPrefix     = "b"
	TXPrefix        = "tx"
	AddressPrefix   = "ad"
	CommitteePrefix = "cp"
)

Constants for storage.

View Source
const (
	Received = "RECEIVED"
	Sent     = "SENT"
)

Tx types ...

Variables

This section is empty.

Functions

func GetAddressKey

func GetAddressKey(address string) string

GetAddressKey ...

func GetBlockInfoKey

func GetBlockInfoKey(id int) string

GetBlockInfoKey ...

func GetBlockKey

func GetBlockKey(id int) string

GetBlockKey ...

func GetCommitteeKey

func GetCommitteeKey(shardID uint32, epoch uint64) string

GetCommitteeKey ...

func GetExplorerPort

func GetExplorerPort(nodePort string) string

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

func GetTXKey

func GetTXKey(hash string) string

GetTXKey ...

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 ...

func NewBlock

func NewBlock(block *types.Block, height int) *Block

NewBlock ...

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 HTTPError

type HTTPError struct {
	Code int
	Msg  string
}

HTTPError is an HTTP error.

type Node

type Node struct {
	ID string `json:"id"`
}

Node ...

type RefBlock

type RefBlock struct {
	ID     string `json:"id"`
	Height string `json:"height"`
}

RefBlock ...

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

func (s *Service) APIs() []rpc.API

APIs for the services.

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

func (s *Service) Init(remove bool)

Init is to initialize for ExplorerService.

func (*Service) NotifyService

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

NotifyService notify service.

func (*Service) ReadBlocksFromDB

func (s *Service) ReadBlocksFromDB(from, to int) []*types.Block

ReadBlocksFromDB returns a list of types.Block to server blocks end-point.

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

type Shard struct {
	Nodes []Node `json:"nodes"`
}

Shard ...

type Storage

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

Storage dump the block info into leveldb.

func GetStorageInstance

func GetStorageInstance(ip, port string, remove bool) *Storage

GetStorageInstance returns attack model by using singleton pattern.

func (*Storage) Dump

func (storage *Storage) Dump(block *types.Block, height uint64)

Dump extracts information from block and index them into lvdb for explorer.

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

func (storage *Storage) Init(ip, port string, remove bool)

Init initializes the block update.

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 ...

type Validator

type Validator struct {
	Address string   `json:"address"`
	Balance *big.Int `json:"balance"`
}

Validator contains harmony validator node address and its balance.

Jump to

Keyboard shortcuts

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