github.com/MetalBlockchain/metalgo@v1.11.9/snow/consensus/snowman/bootstrapper/poll.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package bootstrapper
     5  
     6  import (
     7  	"context"
     8  
     9  	"github.com/MetalBlockchain/metalgo/ids"
    10  	"github.com/MetalBlockchain/metalgo/utils/set"
    11  )
    12  
    13  type Poll interface {
    14  	// GetPeers returns the set of peers whose opinion should be requested. It
    15  	// is expected to repeatedly call this function along with [RecordOpinion]
    16  	// until [Result] returns finalized.
    17  	GetPeers(ctx context.Context) (peers set.Set[ids.NodeID])
    18  	// RecordOpinion of a node whose opinion was requested.
    19  	RecordOpinion(ctx context.Context, nodeID ids.NodeID, blkIDs set.Set[ids.ID]) error
    20  	// Result returns the evaluation of all the peer's opinions along with a
    21  	// flag to identify that the result has finished being calculated.
    22  	Result(ctx context.Context) (blkIDs []ids.ID, finalized bool)
    23  }