indexprotocol

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotExist indicates certain item does not exist in Blockchain database
	ErrNotExist = errors.New("not exist in DB")
	// ErrAlreadyExist indicates certain item already exists in Blockchain database
	ErrAlreadyExist = errors.New("already exist in DB")
	// ErrUnimplemented indicates a method is not implemented yet
	ErrUnimplemented = errors.New("method is unimplemented")
)

Functions

func GetEpochHeight

func GetEpochHeight(epochNum uint64, numDelegates uint64, numSubEpochs uint64) uint64

GetEpochHeight gets the start height of an epoch

func GetEpochNumber

func GetEpochNumber(numDelegates uint64, numSubEpochs uint64, height uint64) uint64

GetEpochNumber gets epoch number

Types

type Account

type Account struct {
	// InitBalanceMap is the address and initial balance mapping before the first block.
	InitBalanceMap map[string]string `yaml:"initBalances"`
}

Account contains the configs for account protocol

type BlockHandler

type BlockHandler interface {
	HandleBlock(context.Context, *sql.Tx, *block.Block) error
}

BlockHandler ishte interface of handling block

type Genesis

type Genesis struct {
	Account `yaml:"account"`
}

Genesis defines the genesis configurations that should be recorded by the corresponding protocol before indexing the first block

type Protocol

type Protocol interface {
	BlockHandler
	CreateTables(context.Context) error
	Initialize(context.Context, *sql.Tx, *Genesis) error
}

Protocol defines the protocol interfaces for block indexer

type Registry

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

Registry is the hub of all protocols deployed on the chain

func (*Registry) All

func (r *Registry) All() []Protocol

All returns all protocols

func (*Registry) Find

func (r *Registry) Find(id string) (Protocol, bool)

Find finds a protocol by ID

func (*Registry) ForceRegister

func (r *Registry) ForceRegister(id string, p Protocol) error

ForceRegister registers the protocol with a unique ID and force replacing the previous protocol if it exists

func (*Registry) Register

func (r *Registry) Register(id string, p Protocol) error

Register registers the protocol with a unique ID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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