manager

package
v0.0.0-...-f30a169 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package manager contains block synchronization logic

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockManager

type BlockManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

BlockManager is the block validation and submission module

func NewBlockManager

func NewBlockManager(ctx context.Context, chainId string, cache *Cache, verifier verifier.Verifier, coder coder.Coder,
	store storage.StateDB, bCh chan common.Blocker, hCh chan *HeightMsg, log *zap.SugaredLogger) *BlockManager

NewBlockManager creates BlockManger

func (*BlockManager) RegisterCallBack

func (bm *BlockManager) RegisterCallBack(callBack CallBack) error

RegisterCallBack registers CallBack

func (*BlockManager) RegisterListener

func (bm *BlockManager) RegisterListener(height uint64, ch chan uint64) bool

RegisterListener registers listener the missing block for prover

func (*BlockManager) RemoveListener

func (bm *BlockManager) RemoveListener(height uint64)

RemoveListener removes listener when prover gets the missing block

func (*BlockManager) Start

func (bm *BlockManager) Start()

Start startups BlockManager

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Cache caches the important variables during block synchronization

func NewCache

func NewCache(current uint64, requestedHeight uint64, remoteMaxHeight uint64) *Cache

NewCache creates Cache

func (*Cache) GetCurrentHeight

func (c *Cache) GetCurrentHeight() uint64

GetCurrentHeight returns currentHeight

func (*Cache) GetRemoteMaxHeight

func (c *Cache) GetRemoteMaxHeight() uint64

GetRemoteMaxHeight returns remoteMaxHeight

func (*Cache) GetRequestedMaxHeight

func (c *Cache) GetRequestedMaxHeight() uint64

GetRequestedMaxHeight returns requestedMaxHeight

func (*Cache) SetCurrentHeight

func (c *Cache) SetCurrentHeight(newCurrent uint64) error

SetCurrentHeight sets currentHeight

func (*Cache) SetRemoteMaxHeight

func (c *Cache) SetRemoteMaxHeight(newRemote uint64) error

SetRemoteMaxHeight sets remoteMaxHeight

func (*Cache) SetRequestedMaxHeight

func (c *Cache) SetRequestedMaxHeight(newRequestHeight uint64) error

SetRequestedMaxHeight sets requestedMaxHeight

type CallBack

type CallBack func(block common.Blocker)

CallBack will be registered by user

type HeightMsg

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

HeightMsg is the block height information missing from spv

type ReqManager

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

ReqManager is the block request module

func NewReqManager

func NewReqManager(ctx context.Context, chainId string, cache *Cache, sdkAdapter adapter.SDKAdapter,
	bCh chan common.Blocker, hCh chan *HeightMsg, log *zap.SugaredLogger) *ReqManager

NewReqManager creates ReqManager

func (*ReqManager) Start

func (rm *ReqManager) Start()

Start startups ReqManager module

type StateManager

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

StateManager is the block synchronization module

func NewStateManager

func NewStateManager(chainId string, sdkAdapter adapter.SDKAdapter, verifier verifier.Verifier, coder coder.Coder,
	store storage.StateDB, log *zap.SugaredLogger) *StateManager

NewStateManager creates StateManger

func (*StateManager) GetBlockManager

func (sm *StateManager) GetBlockManager() *BlockManager

GetBlockManager returns block manger

func (*StateManager) MonitorSubscribeBlock

func (sm *StateManager) MonitorSubscribeBlock()

MonitorSubscribeBlock monitors and resubscribes block when the connection is broken

func (*StateManager) Start

func (sm *StateManager) Start() error

Start startups StateManager

func (*StateManager) StartupChainInfoLoop

func (sm *StateManager) StartupChainInfoLoop()

StartupChainInfoLoop polls the latest block height of the remote chain periodically

func (*StateManager) Stop

func (sm *StateManager) Stop() error

Stop stops StateManager

func (*StateManager) SubscribeBlock

func (sm *StateManager) SubscribeBlock() error

SubscribeBlock subscribes the latest block from remote chain

Jump to

Keyboard shortcuts

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