protocol

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: GPL-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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`)
)
View Source
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.

func (*PriorityQueue) Put

func (pq *PriorityQueue) Put(items ...*types.Block) error

Put adds items to 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

func (*Status) Copy

func (s *Status) Copy() *Status

Copy creates a copy of the status

type SyncPeer

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

SyncPeer is a representation of the peer the node is syncing with

func (*SyncPeer) ID

func (s *SyncPeer) ID() peer.ID

func (*SyncPeer) IsClosed

func (s *SyncPeer) IsClosed() bool

IsClosed returns whether peer's connectivity has been closed

func (*SyncPeer) Number

func (s *SyncPeer) Number() uint64

Number returns the latest peer block height

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

func (s *Syncer) AddPeer(peerID peer.ID) error

AddPeer establishes new connection with the given peer

func (*Syncer) BestPeer

func (s *Syncer) BestPeer() *SyncPeer

BestPeer returns the best peer by difficulty (if any)

func (*Syncer) Broadcast

func (s *Syncer) Broadcast(b *types.Block)

Broadcast broadcasts a block to all peers

func (*Syncer) Close

func (s *Syncer) Close() error

func (*Syncer) DeletePeer

func (s *Syncer) DeletePeer(peerID peer.ID) error

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

func (s *Syncer) Start(ctx context.Context)

Start starts the syncer protocol

func (*Syncer) StartToRecieveNewBlock

func (s *Syncer) StartToRecieveNewBlock()

func (*Syncer) SyncWork

func (s *Syncer) SyncWork(ctx context.Context)

number: 687 have tx

func (*Syncer) TakePeerByHeight

func (s *Syncer) TakePeerByHeight(height, num uint64) []*SyncPeer

func (*Syncer) WatchSync

func (s *Syncer) WatchSync(ctx context.Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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