Documentation ¶
Index ¶
- Constants
- Variables
- func UseLogger(logger *logger.Logger)
- type ChainService
- func (cs *ChainService) GetBest(p peer.ID) (types.ID, uint32, error)
- func (cs *ChainService) GetBlock(p peer.ID, blockID types.ID) (*blocks.Block, error)
- func (cs *ChainService) GetBlockID(p peer.ID, height uint32) (types.ID, error)
- func (cs *ChainService) GetBlockTxids(p peer.ID, blockID types.ID) ([]types.ID, error)
- func (cs *ChainService) GetBlockTxs(p peer.ID, blockID types.ID, txIndexes []uint32) ([]*transactions.Transaction, error)
- func (cs *ChainService) GetBlockTxsStream(p peer.ID, startHeight uint32) (<-chan *blocks.BlockTxs, error)
- func (cs *ChainService) GetHeadersStream(p peer.ID, startHeight uint32) (<-chan *blocks.BlockHeader, error)
- func (cs *ChainService) HandleNewStream(s inet.Stream)
- type ConsensusChooser
- type FetchBlockFunc
- type SyncManager
- type SyncManagerConfig
Constants ¶
View Source
const ( ChainServiceProtocol = "/chainservice/" ChainServiceProtocolVersion = "1.0.0" )
Variables ¶
View Source
var ErrNotCurrent = errors.New("peer not current")
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
Types ¶
type ChainService ¶
type ChainService struct {
// contains filtered or unexported fields
}
func NewChainService ¶
func NewChainService(ctx context.Context, fetchBlock FetchBlockFunc, chain *blockchain.Blockchain, network *net.Network, params *params.NetworkParams) (*ChainService, error)
func (*ChainService) GetBlockID ¶
func (*ChainService) GetBlockTxids ¶
func (*ChainService) GetBlockTxs ¶
func (cs *ChainService) GetBlockTxs(p peer.ID, blockID types.ID, txIndexes []uint32) ([]*transactions.Transaction, error)
func (*ChainService) GetBlockTxsStream ¶
func (*ChainService) GetHeadersStream ¶
func (cs *ChainService) GetHeadersStream(p peer.ID, startHeight uint32) (<-chan *blocks.BlockHeader, error)
func (*ChainService) HandleNewStream ¶
func (cs *ChainService) HandleNewStream(s inet.Stream)
type ConsensusChooser ¶
ConsensusChooser is an interface function which polls the consensus engine to determine the best block at the height.
type SyncManager ¶
type SyncManager struct {
// contains filtered or unexported fields
}
SyncManager is responsible for trustlessly syncing the blockchain to the tip of the chain.
func NewSyncManager ¶
func NewSyncManager(cfg *SyncManagerConfig) *SyncManager
NewSyncManager returns a new initialized SyncManager
func (*SyncManager) Close ¶
func (sm *SyncManager) Close()
Close stops the sync and resets the SyncManager. It can be restarted after this point.
func (*SyncManager) IsCurrent ¶
func (sm *SyncManager) IsCurrent() bool
IsCurrent returns whether the SyncManager believes it is synced to the tip of the chain.
func (*SyncManager) SetCurrent ¶
func (sm *SyncManager) SetCurrent()
SetCurrent sets the sync manager to current. This will stop the sync.
func (*SyncManager) Start ¶
func (sm *SyncManager) Start()
Start begins the process of syncing to the tip of the chain
type SyncManagerConfig ¶
type SyncManagerConfig struct { Ctx context.Context Chain *blockchain.Blockchain Network *net.Network Params *params.NetworkParams CS *ChainService Chooser ConsensusChooser ProofCache *blockchain.ProofCache SigCache *blockchain.SigCache Verifier zk.Verifier IsCurrentCallback func() }
SyncManagerConfig holds the configuration options for the SyncManager
Click to show internal directories.
Click to hide internal directories.