peerutil

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: Apache-2.0, MIT Imports: 2 Imported by: 1

Documentation

Overview

Package peerutil provides utilities around peer ID values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

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

Policy is a boolean value with a set of zero or more peer ID values. Evaluating a peer ID returns the boolean value, or its opposite if the peer ID is in the set of IDs.

This serves a basis for simple policies where the boolean value applies to all peers except those in the set of peer IDs.

func NewPolicy

func NewPolicy(value bool, except ...peer.ID) Policy

New creates a new Policy.

The Policy evaluates to the given boolean value for all peers, except those listed in the except list.

func NewPolicyStrings

func NewPolicyStrings(value bool, except []string) (Policy, error)

func (*Policy) Any

func (p *Policy) Any(value bool) bool

Any returns true if any it is possible for a true value to be returned.

func (*Policy) Default

func (p *Policy) Default() bool

Default returns the default value.

func (*Policy) Eval

func (p *Policy) Eval(peerID peer.ID) bool

Eval returns the boolean value for the specified peer.

func (*Policy) Except

func (p *Policy) Except() []peer.ID

Except returns the except list as a slice of peer.ID.

func (*Policy) ExceptStrings

func (p *Policy) ExceptStrings() []string

ExceptStrings returns the except list as a slice of peer.ID strings.

func (*Policy) SetPeer

func (p *Policy) SetPeer(peerID peer.ID, value bool) bool

SetPeer ensures that the specified peer evaluates to the specified value, altering the except set if needed. Returns true if the except set was updated.

Jump to

Keyboard shortcuts

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