Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockIterator ¶
type BlockIterator struct {
// contains filtered or unexported fields
}
BlockIterator wraps around ledger as a iterator style interface
func NewBlockIterator ¶
func NewBlockIterator(blockStore BlockStore, startNum, endNum int64) *BlockIterator
func (*BlockIterator) Block ¶
func (b *BlockIterator) Block() *pb.InternalBlock
func (*BlockIterator) Close ¶
func (b *BlockIterator) Close()
func (*BlockIterator) Data ¶
func (b *BlockIterator) Data() interface{}
func (*BlockIterator) Data2 ¶
func (b *BlockIterator) Data2() interface{}
func (*BlockIterator) Error ¶
func (b *BlockIterator) Error() error
func (*BlockIterator) Next ¶
func (b *BlockIterator) Next() bool
type BlockStore ¶
type BlockStore interface {
// TipBlockHeight returns the tip block height
TipBlockHeight() (int64, error)
// WaitBlockHeight wait until the height of current block height >= target
WaitBlockHeight(target int64) int64
// QueryBlockByHeight returns block at given height
QueryBlockByHeight(int64) (*pb.InternalBlock, error)
}
BlockStore is the interface of block store
func NewBlockStore ¶
func NewBlockStore(ledger *ledger.Ledger, state *state.State) BlockStore
NewBlockStore wraps ledger and utxovm as a BlockStore
type BlockTopic ¶
type BlockTopic struct {
// contains filtered or unexported fields
}
BlockTopic handles block events
func NewBlockTopic ¶
func NewBlockTopic(chainmg ChainManager) *BlockTopic
NewBlockTopic instances BlockTopic from ChainManager
func (*BlockTopic) MarshalEvent ¶
func (b *BlockTopic) MarshalEvent(x interface{}) ([]byte, error)
MarshalEvent encode event payload returns from Iterator.Data()
func (*BlockTopic) NewFilterIterator ¶
func (b *BlockTopic) NewFilterIterator(pbfilter *protos.BlockFilter) (Iterator, error)
NewFilterIterator make a new Iterator base on filter
func (*BlockTopic) NewIterator ¶
func (b *BlockTopic) NewIterator(ifilter interface{}) (Iterator, error)
NewIterator make a new Iterator base on filter
func (*BlockTopic) ParseFilter ¶
func (b *BlockTopic) ParseFilter(buf []byte) (interface{}, error)
ParseFilter 从指定的bytes buffer反序列化topic过滤器 返回的参数会作为入参传递给NewIterator的filter参数
type ChainManager ¶
type ChainManager interface {
// GetBlockStore get BlockStore base bcname(the name of block chain)
GetBlockStore(bcname string) (BlockStore, error)
}
ChainManager manage multiple block chain
func NewChainManager ¶
func NewChainManager(engine common.Engine) ChainManager
NewChainManager returns ChainManager as the wrapper of xchaincore.XChainMG
type EncodeFunc ¶
EncodeFunc encodes event payload
type Iterator ¶
type Iterator interface {
Next() bool
Data() interface{}
Error() error
Close()
Data2() interface{}
}
Iterator is the event iterator, must be closed after use
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router distribute events according to the event type and filter
func NewRounterFromChainMG ¶
func NewRounterFromChainMG(chainmg ChainManager) *Router
NewRounterFromChainMG instance Router from ChainManager
func (*Router) RawSubscribe ¶
func (r *Router) RawSubscribe(tp pb.SubscribeType, filter interface{}) (Iterator, error)
RawSubscribe route events from pb.SubscribeType and filter struct
func (*Router) Subscribe ¶
func (r *Router) Subscribe(tp pb.SubscribeType, filterbuf []byte) (EncodeFunc, Iterator, error)
Subscribe route events from pb.SubscribeType and filter buffer
type Topic ¶
type Topic interface {
// ParseFilter 从指定的bytes buffer反序列化topic过滤器
// 返回的参数会作为入参传递给NewIterator的filter参数
ParseFilter(buf []byte) (interface{}, error)
// MarshalEvent encode event payload returns from Iterator.Data()
MarshalEvent(x interface{}) ([]byte, error)
// NewIterator make a new Iterator base on filter
NewIterator(filter interface{}) (Iterator, error)
}
Topic is the factory of event Iterator