Documentation ¶
Index ¶
Constants ¶
const ( // ResultSuccess indicates operation was successful and no extra action is required ResultSuccess result = iota // ResultSynced will save the status of pool as "synced" and will remove peers from it ResultSynced // ResultCooldownPeer will put returned peer on cooldown, meaning it won't be available by Peer // method for some time ResultCooldownPeer // ResultBlacklistPeer will blacklist peer. Blacklisted peers will be disconnected and blocked from // any p2p communication in future by libp2p Gater ResultBlacklistPeer )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DoneFunc ¶
type DoneFunc func(result)
DoneFunc updates internal state depending on call results. Should be called once per returned peer from Peer method
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager keeps track of peers coming from shrex.Sub and from discovery
func NewManager ¶
func NewManager( params Parameters, headerSub libhead.Subscriber[*header.ExtendedHeader], shrexSub *shrexsub.PubSub, discovery *discovery.Discovery, host host.Host, connGater *conngater.BasicConnectionGater, ) (*Manager, error)
func (*Manager) Peer ¶
Peer returns peer collected from shrex.Sub for given datahash if any available. If there is none, it will look for full nodes collected from discovery. If there is no discovered full nodes, it will wait until any peer appear in either source or timeout happen. After fetching data using given peer, caller is required to call returned DoneFunc using appropriate result value
type Parameters ¶
type Parameters struct { // PoolValidationTimeout is the timeout used for validating incoming datahashes. Pools that have // been created for datahashes from shrexsub that do not see this hash from headersub after this // timeout will be garbage collected. PoolValidationTimeout time.Duration // PeerCooldown is the time a peer is put on cooldown after a ResultCooldownPeer. PeerCooldown time.Duration // GcInterval is the interval at which the manager will garbage collect unvalidated pools. GcInterval time.Duration // EnableBlackListing turns on blacklisting for misbehaved peers EnableBlackListing bool }
func DefaultParameters ¶
func DefaultParameters() Parameters
DefaultParameters returns the default configuration values for the daser parameters
func (*Parameters) Validate ¶
func (p *Parameters) Validate() error
Validate validates the values in Parameters