manager

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 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, 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

func (*BlockManager) Start

func (bm *BlockManager) Start()

Start startups BlockManager

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

func NewHeightMsg

func NewHeightMsg(height uint64, isRemote bool) *HeightMsg

NewHeightMsg create HeightMsg

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

func (*ReqManager) Start

func (rm *ReqManager) Start()

Start startups ReqManager module

type State

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

State caches the important variables during block synchronization

func NewState

func NewState(current uint64, requestedHeight uint64, remoteMaxHeight uint64) *State

NewState creates State

func (*State) GetCurrentHeight

func (s *State) GetCurrentHeight() uint64

GetCurrentHeight returns currentHeight

func (*State) GetLocalHeight

func (s *State) GetLocalHeight() uint64

GetLocalHeight returns local height

func (*State) GetRemoteMaxHeight

func (s *State) GetRemoteMaxHeight() uint64

GetRemoteMaxHeight returns remoteMaxHeight

func (*State) GetRequestedMaxHeight

func (s *State) GetRequestedMaxHeight() uint64

GetRequestedMaxHeight returns requestedMaxHeight

func (*State) SetCurrentHeight

func (s *State) SetCurrentHeight(newCurrent uint64) error

SetCurrentHeight sets currentHeight

func (*State) SetRemoteMaxHeight

func (s *State) SetRemoteMaxHeight(newRemote uint64) error

SetRemoteMaxHeight sets remoteMaxHeight

func (*State) SetRequestedMaxHeight

func (s *State) SetRequestedMaxHeight(newRequestHeight uint64) error

SetRequestedMaxHeight sets requestedMaxHeight

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) Start

func (sm *StateManager) Start() error

Start startups StateManager

func (*StateManager) StartupChainHeightLoop

func (sm *StateManager) StartupChainHeightLoop()

StartupChainHeightLoop 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