Documentation
¶
Overview ¶
Package manager contains block synchronization logic
Index ¶
- type BlockManager
- type Cache
- func (c *Cache) GetCurrentHeight() uint64
- func (c *Cache) GetRemoteMaxHeight() uint64
- func (c *Cache) GetRequestedMaxHeight() uint64
- func (c *Cache) SetCurrentHeight(newCurrent uint64) error
- func (c *Cache) SetRemoteMaxHeight(newRemote uint64) error
- func (c *Cache) SetRequestedMaxHeight(newRequestHeight uint64) error
- type CallBack
- type HeightMsg
- type ReqManager
- type StateManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockManager ¶
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
type Cache ¶
Cache caches the important variables during block synchronization
func NewCache ¶
NewCache creates Cache
func (*Cache) GetCurrentHeight ¶
GetCurrentHeight returns currentHeight
func (*Cache) GetRemoteMaxHeight ¶
GetRemoteMaxHeight returns remoteMaxHeight
func (*Cache) GetRequestedMaxHeight ¶
GetRequestedMaxHeight returns requestedMaxHeight
func (*Cache) SetCurrentHeight ¶
SetCurrentHeight sets currentHeight
func (*Cache) SetRemoteMaxHeight ¶
SetRemoteMaxHeight sets remoteMaxHeight
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
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) StartupChainInfoLoop ¶
func (sm *StateManager) StartupChainInfoLoop()
StartupChainInfoLoop polls the latest block height of the remote chain periodically
func (*StateManager) SubscribeBlock ¶
func (sm *StateManager) SubscribeBlock() error
SubscribeBlock subscribes the latest block from remote chain