Documentation ¶
Overview ¶
Package manager contains block synchronization logic
Index ¶
- type BlockManager
- type CallBack
- type HeightMsg
- type ReqManager
- type State
- func (s *State) GetCurrentHeight() uint64
- func (s *State) GetLocalHeight() uint64
- func (s *State) GetRemoteMaxHeight() uint64
- func (s *State) GetRequestedMaxHeight() uint64
- func (s *State) SetCurrentHeight(newCurrent uint64) error
- func (s *State) SetRemoteMaxHeight(newRemote uint64) error
- func (s *State) SetRequestedMaxHeight(newRequestHeight uint64) error
- type StateManager
- func (sm *StateManager) GetBlockManager() *BlockManager
- func (sm *StateManager) MonitorSubscribeBlock()
- func (sm *StateManager) RequestChainHeight()
- func (sm *StateManager) Start() error
- func (sm *StateManager) StartupChainHeightLoop()
- func (sm *StateManager) Stop() error
- func (sm *StateManager) SubscribeBlock() error
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, state *State, 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 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, state *State, sdkAdapter adapter.SDKAdapter, bCh chan common.Blocker, hCh chan *HeightMsg, log *zap.SugaredLogger) *ReqManager
NewReqManager creates ReqManager
type State ¶
State caches the important variables during block synchronization
func NewState ¶
NewState creates State
func (*State) GetCurrentHeight ¶
GetCurrentHeight returns currentHeight
func (*State) GetLocalHeight ¶
GetLocalHeight returns local height
func (*State) GetRemoteMaxHeight ¶
GetRemoteMaxHeight returns remoteMaxHeight
func (*State) GetRequestedMaxHeight ¶
GetRequestedMaxHeight returns requestedMaxHeight
func (*State) SetCurrentHeight ¶
SetCurrentHeight sets currentHeight
func (*State) SetRemoteMaxHeight ¶
SetRemoteMaxHeight sets remoteMaxHeight
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager is the block synchronization module
func NewStateManager ¶
func NewStateManager(chainId string, blockInterval int32, 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) RequestChainHeight ¶
func (sm *StateManager) RequestChainHeight()
RequestChainHeight requests remote chain height
func (*StateManager) StartupChainHeightLoop ¶
func (sm *StateManager) StartupChainHeightLoop()
StartupChainHeightLoop 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