Documentation ¶
Index ¶
- Constants
- func AssertPeersEqual(t *testing.T, sp *storage.Peer, p Peer)
- func FromAddress(id id.ID, name string, addr *net.TCPAddr) *api.PeerAddress
- func NewTestPublicAddr(idx int) *net.TCPAddr
- func NewTestStoredPeer(rng *rand.Rand, idx int) *storage.Peer
- func ToAPIs(peers []Peer) []*api.PeerAddress
- func ToAddress(addr *api.PeerAddress) *net.TCPAddr
- type Fromer
- type Peer
Constants ¶
const (
// MissingName is the placeholder for a missing peer name.
MissingName = "MISING_NAME"
)
Variables ¶
This section is empty.
Functions ¶
func AssertPeersEqual ¶
AssertPeersEqual checks that the stored and non-stored representations of a peer are equal.
func FromAddress ¶
FromAddress creates an api.PeerAddress from a net.TCPAddr.
func NewTestPublicAddr ¶
NewTestPublicAddr creates a new net.TCPAddr given a particular peer index.
func NewTestStoredPeer ¶
NewTestStoredPeer generates a new storage.Peer suitable for testing using a random number generator for the ID and an index.
func ToAPIs ¶
func ToAPIs(peers []Peer) []*api.PeerAddress
ToAPIs converts a list of peers into a list of api.PeerAddress objects.
Types ¶
type Fromer ¶
type Fromer interface { // FromAPI creates a new Peer instance. FromAPI(address *api.PeerAddress) Peer }
Fromer creates new Peer instances from api.PeerAddresses.
type Peer ¶
type Peer interface { // ID returns the peer ID. ID() id.ID // Address returns the public address of the peer. Address() *net.TCPAddr // Merge merges another peer into the existing peer. If there is any conflicting information // between the two, the merge returns an error. Merge(other Peer) error // ToStored returns a storage.Peer version of the peer. ToStored() *storage.Peer // ToAPI returns an api.PeerAddress version of the peer. ToAPI() *api.PeerAddress }
Peer represents a peer in the network.
func FromStored ¶
FromStored creates a new peer.Peer instance from a storage.Peer instance.
func NewTestPeer ¶
NewTestPeer generates a new peer suitable for testing using a random number generator for the ID and an index.