PeerRecord class

PeerRecord contains information that is broadly useful to share with other peers, either through a direct exchange (as in the libp2p identify protocol), or through a Peer Routing provider, such as a DHT.

Currently, a PeerRecord contains the public listen addresses for a peer, but this is expected to expand to include other information in the future.

PeerRecords are ordered in time by their Seq field. Newer PeerRecords must have greater Seq values than older records. The NewPeerRecord function will create a PeerRecord with a timestamp-based Seq value.

Implemented types

Constructors

PeerRecord.new({required PeerId peerId, required List<MultiAddr> addrs, required int seq})
PeerRecord.fromProtobuf(PeerRecord msg)
Creates a PeerRecord from a protobuf PeerRecord struct.
factory

Properties

addrs List<MultiAddr>
Addrs contains the public addresses of the peer this record pertains to.
final
hashCode int
The hash code for this object.
no setterinherited
peerId PeerId
PeerID is the ID of the peer this record pertains to.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
seq int
Seq is a monotonically-increasing sequence counter that's used to order PeerRecords in time. The interval between Seq values is unspecified, but newer PeerRecords MUST have a greater Seq value than older records for the same peer.
final

Methods

codec() Uint8List
Codec is a binary identifier for the PeerRecord type. It is constant for all PeerRecord instances.
override
domain() String
Domain is used when signing and validating PeerRecords contained in Envelopes. It is constant for all PeerRecord instances.
override
equal(PeerRecord other) bool
Equal returns true if the other PeerRecord is identical to this one.
marshalRecord() Uint8List
MarshalRecord serializes a PeerRecord to a byte slice. This method is called automatically when constructing a routing.Envelope using Seal or PeerRecord.Sign.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toProtobuf() PeerRecord
ToProtobuf returns the equivalent Protocol Buffer struct object of a PeerRecord.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromAddrInfo(AddrInfo info) Future<PeerRecord>
Creates a PeerRecord from an AddrInfo struct. The returned record will have a timestamp-based sequence number.
fromProtobufBytes(Uint8List payload) PeerRecord
UnmarshalRecord parses a PeerRecord from a byte slice. This method is called automatically when consuming a record.Envelope whose PayloadType indicates that it contains a PeerRecord. Unmarshal a record payload into a concrete PeerRecord instance
newRecord() Future<PeerRecord>
Creates a new PeerRecord with a timestamp-based sequence number. The returned record is otherwise empty and should be populated by the caller.