sync

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

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

func UpdateLogger

func UpdateLogger()

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

func (*ChainService) GetBest

func (cs *ChainService) GetBest(p peer.ID) (types.ID, uint32, error)

func (*ChainService) GetBlock

func (cs *ChainService) GetBlock(p peer.ID, blockID types.ID) (*blocks.Block, error)

func (*ChainService) GetBlockID

func (cs *ChainService) GetBlockID(p peer.ID, height uint32) (types.ID, error)

func (*ChainService) GetBlockTxids

func (cs *ChainService) GetBlockTxids(p peer.ID, blockID types.ID) ([]types.ID, error)

func (*ChainService) GetBlockTxs

func (cs *ChainService) GetBlockTxs(p peer.ID, blockID types.ID, txIndexes []uint32) ([]*transactions.Transaction, error)

func (*ChainService) GetBlockTxsStream

func (cs *ChainService) GetBlockTxsStream(p peer.ID, startHeight uint32) (<-chan *blocks.BlockTxs, error)

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

type ConsensusChooser func([]*blocks.Block) (types.ID, error)

type FetchBlockFunc

type FetchBlockFunc func(blockID types.ID) (*blocks.Block, error)

type SyncManager

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

func NewSyncManager

func NewSyncManager(ctx context.Context, chain *blockchain.Blockchain, network *net.Network, params *params.NetworkParams, cs *ChainService, chooser ConsensusChooser, isCurrentCallback func()) *SyncManager

func (*SyncManager) Close

func (sm *SyncManager) Close()

func (*SyncManager) IsCurrent

func (sm *SyncManager) IsCurrent() bool

func (*SyncManager) SetCurrent

func (sm *SyncManager) SetCurrent()

func (*SyncManager) Start

func (sm *SyncManager) Start()

Jump to

Keyboard shortcuts

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