Documentation ¶
Index ¶
- Variables
- type PriorityQueue
- func (pq *PriorityQueue) Dispose()
- func (pq *PriorityQueue) Disposed() bool
- func (pq *PriorityQueue) Empty() bool
- func (pq *PriorityQueue) Get(number int) ([]*types.Block, error)
- func (pq *PriorityQueue) Latest() uint64
- func (pq *PriorityQueue) Len() int
- func (pq *PriorityQueue) Peek() *types.Block
- func (pq *PriorityQueue) Put(items ...*types.Block) error
- type Status
- type SyncPeer
- type Syncer
- func (s *Syncer) AddPeer(peerID peer.ID) error
- func (s *Syncer) BestPeer() *SyncPeer
- func (s *Syncer) Broadcast(b *types.Block)
- func (s *Syncer) Close() error
- func (s *Syncer) DeletePeer(peerID peer.ID) error
- func (s *Syncer) GetSyncProgression() *progress.Progression
- func (s *Syncer) Start(ctx context.Context)
- func (s *Syncer) StartToRecieveNewBlock()
- func (s *Syncer) SyncWork(ctx context.Context)
- func (s *Syncer) TakePeerByHeight(height, num uint64) []*SyncPeer
- func (s *Syncer) WatchSync(ctx context.Context)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDisposed is returned when an operation is performed on a disposed // queue. ErrDisposed = errors.New(`queue: disposed`) // ErrTimeout is returned when an applicable queue operation times out. ErrTimeout = errors.New(`queue: poll timed out`) // ErrEmptyQueue is returned when an non-applicable queue operation was called // due to the queue's empty item state ErrEmptyQueue = errors.New(`queue: empty queue`) )
var ( ErrLoadLocalGenesisFailed = errors.New("failed to read local genesis") ErrMismatchGenesis = errors.New("genesis does not match") ErrCommonAncestorNotFound = errors.New("header is nil") ErrForkNotFound = errors.New("fork not found") ErrPopTimeout = errors.New("timeout") ErrConnectionClosed = errors.New("connection closed") ErrTooManyHeaders = errors.New("unexpected more than 1 result") ErrDecodeDifficulty = errors.New("failed to decode difficulty") ErrInvalidTypeAssertion = errors.New("invalid type assertion") )
Functions ¶
This section is empty.
Types ¶
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue is similar to queue except that it takes items that implement the Item interface and adds them to the queue i order.
func NewPriorityQueue ¶
func NewPriorityQueue(hint int, allowDuplicates bool) *PriorityQueue
NewPriorityQueue is the constructor for a priority queue.
func (*PriorityQueue) Dispose ¶
func (pq *PriorityQueue) Dispose()
Dispose will prevent any further reads/writes to this queue and frees available resources.
func (*PriorityQueue) Disposed ¶
func (pq *PriorityQueue) Disposed() bool
Disposed returns a bool indicating if this queue has been disposed.
func (*PriorityQueue) Empty ¶
func (pq *PriorityQueue) Empty() bool
Empty returns a bool indicating if there are any items left in the queue.
func (*PriorityQueue) Get ¶
func (pq *PriorityQueue) Get(number int) ([]*types.Block, error)
Get retrieves items from the queue. If the queue is empty, this call blocks until the next item is added to the queue. This will attempt to retrieve number of items.
func (*PriorityQueue) Latest ¶
func (pq *PriorityQueue) Latest() uint64
func (*PriorityQueue) Len ¶
func (pq *PriorityQueue) Len() int
Len returns a number indicating how many items are in the queue.
func (*PriorityQueue) Peek ¶
func (pq *PriorityQueue) Peek() *types.Block
Peek will look at the next item without removing it from the queue.
type Status ¶
type Status struct { Difficulty *big.Int // Current difficulty Hash types.Hash // Latest block hash Number uint64 // Latest block number }
Status defines the up to date information regarding the peer
type SyncPeer ¶
type SyncPeer struct {
// contains filtered or unexported fields
}
SyncPeer is a representation of the peer the node is syncing with
func (*SyncPeer) Status ¶
func (s *SyncPeer) Status() connectivity.State
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer is a sync protocol
func NewSyncer ¶
func NewSyncer(logger hclog.Logger, server *network.Server, blockchain blockchainShim, datadir string) *Syncer
NewSyncer creates a new Syncer instance
func (*Syncer) DeletePeer ¶
DeletePeer deletes a peer from syncer
func (*Syncer) GetSyncProgression ¶
func (s *Syncer) GetSyncProgression() *progress.Progression
GetSyncProgression returns the latest sync progression, if any
func (*Syncer) StartToRecieveNewBlock ¶
func (s *Syncer) StartToRecieveNewBlock()