bootstrapper

package
v1.11.11-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sample

func Sample[T comparable](elements map[T]uint64, maxSize int) (set.Set[T], error)

Sample keys from [elements] uniformly by weight without replacement. The returned set will have size less than or equal to [maxSize]. This function will error if the sum of all weights overflows.

Types

type Majority

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

Majority implements the bootstrapping poll to filter the initial set of potentially accaptable blocks into a set of accepted blocks to sync to.

Once the last accepted blocks have been fetched from the initial set of peers, the set of blocks are sent to all peers. Each peer is expected to filter the provided blocks and report which of them they consider accepted. If a majority of the peers report that a block is accepted, then the node will consider that block to be accepted by the network. This assumes that a majority of the network is correct. If a majority of the network is malicious, the node may accept an incorrect block.

func NewMajority

func NewMajority(
	log logging.Logger,
	nodeWeights map[ids.NodeID]uint64,
	maxOutstanding int,
) *Majority

func (*Majority) GetPeers

func (r *Majority) GetPeers(context.Context) set.Set[ids.NodeID]

func (*Majority) RecordOpinion

func (m *Majority) RecordOpinion(_ context.Context, nodeID ids.NodeID, blkIDs set.Set[ids.ID]) error

func (*Majority) Result

func (m *Majority) Result(context.Context) ([]ids.ID, bool)

type Minority

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

Minority implements the bootstrapping poll to determine the initial set of potentially accaptable blocks.

This poll fetches the last accepted block from an initial set of peers. In order for the protocol to find a recently accepted block, there must be at least one correct node in this set of peers. If there is not a correct node in the set of peers, the node will not accept an incorrect block. However, the node may be unable to find an acceptable block.

func NewMinority

func NewMinority(
	log logging.Logger,
	frontierNodes set.Set[ids.NodeID],
	maxOutstanding int,
) *Minority

func (*Minority) GetPeers

func (r *Minority) GetPeers(context.Context) set.Set[ids.NodeID]

func (*Minority) RecordOpinion

func (m *Minority) RecordOpinion(_ context.Context, nodeID ids.NodeID, blkIDs set.Set[ids.ID]) error

func (*Minority) Result

func (m *Minority) Result(context.Context) ([]ids.ID, bool)

type Poll

type Poll interface {
	// GetPeers returns the set of peers whose opinion should be requested. It
	// is expected to repeatedly call this function along with [RecordOpinion]
	// until [Result] returns finalized.
	GetPeers(ctx context.Context) (peers set.Set[ids.NodeID])
	// RecordOpinion of a node whose opinion was requested.
	RecordOpinion(ctx context.Context, nodeID ids.NodeID, blkIDs set.Set[ids.ID]) error
	// Result returns the evaluation of all the peer's opinions along with a
	// flag to identify that the result has finished being calculated.
	Result(ctx context.Context) (blkIDs []ids.ID, finalized bool)
}
var Noop Poll = noop{}

Jump to

Keyboard shortcuts

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