docs: uniform comment sentences

This commit is contained in:
Vasco Santos 2020-03-03 18:16:38 +01:00
parent ee95739931
commit 43f10f2288
7 changed files with 20 additions and 20 deletions

View File

@ -61,7 +61,7 @@ type ConnManager interface {
// See notes on Protect() for more info. // See notes on Protect() for more info.
Unprotect(id peer.ID, tag string) (protected bool) Unprotect(id peer.ID, tag string) (protected bool)
// Close closes the connection manager and stops background processes // Close closes the connection manager and stops background processes.
Close() error Close() error
} }

View File

@ -74,7 +74,7 @@ func AddrInfoFromP2pAddr(m ma.Multiaddr) (*AddrInfo, error) {
return info, nil return info, nil
} }
// AddrInfoToP2pAddr converts an AddrInfo to a list of Multiaddrs. // AddrInfoToP2pAddrs converts an AddrInfo to a list of Multiaddrs.
func AddrInfoToP2pAddrs(pi *AddrInfo) ([]ma.Multiaddr, error) { func AddrInfoToP2pAddrs(pi *AddrInfo) ([]ma.Multiaddr, error) {
var addrs []ma.Multiaddr var addrs []ma.Multiaddr
p2ppart, err := ma.NewComponent("p2p", IDB58Encode(pi.ID)) p2ppart, err := ma.NewComponent("p2p", IDB58Encode(pi.ID))

View File

@ -57,7 +57,7 @@ func (id ID) String() string {
return id.Pretty() return id.Pretty()
} }
// String prints out the peer ID. // ShortString prints out the peer ID.
// //
// TODO(brian): ensure correctness at ID generation and // TODO(brian): ensure correctness at ID generation and
// enforce this by only exposing functions that generate // enforce this by only exposing functions that generate
@ -85,7 +85,7 @@ func (id ID) MatchesPublicKey(pk ic.PubKey) bool {
return oid == id return oid == id
} }
// ExtractPublicKey attempts to extract the public key from an ID // ExtractPublicKey attempts to extract the public key from an ID.
// //
// This method returns ErrNoPublicKey if the peer ID looks valid but it can't extract // This method returns ErrNoPublicKey if the peer ID looks valid but it can't extract
// the public key. // the public key.
@ -237,7 +237,7 @@ func IDFromPrivateKey(sk ic.PrivKey) (ID, error) {
return IDFromPublicKey(sk.GetPublic()) return IDFromPublicKey(sk.GetPublic())
} }
// IDSlice for sorting peers // IDSlice for sorting peers.
type IDSlice []ID type IDSlice []ID
func (es IDSlice) Len() int { return len(es) } func (es IDSlice) Len() int { return len(es) }

View File

@ -1,4 +1,4 @@
// This file contains Protobuf and JSON serialization/deserialization methods for peer IDs. // Package peer contains Protobuf and JSON serialization/deserialization methods for peer IDs.
package peer package peer
import ( import (
@ -21,7 +21,7 @@ func (id ID) Marshal() ([]byte, error) {
return []byte(id), nil return []byte(id), nil
} }
// BinaryMarshal returns the byte representation of the peer ID. // MarshalBinary returns the byte representation of the peer ID.
func (id ID) MarshalBinary() ([]byte, error) { func (id ID) MarshalBinary() ([]byte, error) {
return id.Marshal() return id.Marshal()
} }
@ -35,12 +35,12 @@ func (id *ID) Unmarshal(data []byte) (err error) {
return err return err
} }
// BinaryUnmarshal sets the ID from its binary representation. // UnmarshalBinary sets the ID from its binary representation.
func (id *ID) UnmarshalBinary(data []byte) error { func (id *ID) UnmarshalBinary(data []byte) error {
return id.Unmarshal(data) return id.Unmarshal(data)
} }
// Implements Gogo's proto.Sizer, but we omit the compile-time assertion to avoid introducing a hard // Size implements Gogo's proto.Sizer, but we omit the compile-time assertion to avoid introducing a hard
// dependency on gogo. // dependency on gogo.
func (id ID) Size() int { func (id ID) Size() int {
return len([]byte(id)) return len([]byte(id))
@ -59,12 +59,12 @@ func (id *ID) UnmarshalJSON(data []byte) (err error) {
return err return err
} }
// TextMarshal returns the text encoding of the ID. // MarshalText returns the text encoding of the ID.
func (id ID) MarshalText() ([]byte, error) { func (id ID) MarshalText() ([]byte, error) {
return []byte(IDB58Encode(id)), nil return []byte(IDB58Encode(id)), nil
} }
// TextUnmarshal restores the ID from its text encoding. // UnmarshalText restores the ID from its text encoding.
func (id *ID) UnmarshalText(data []byte) error { func (id *ID) UnmarshalText(data []byte) error {
pid, err := IDB58Decode(string(data)) pid, err := IDB58Decode(string(data))
if err != nil { if err != nil {

View File

@ -18,12 +18,12 @@ func init() {
record.RegisterType(&PeerRecord{}) record.RegisterType(&PeerRecord{})
} }
// The domain string used for peer records contained in a Envelope. // PeerRecordEnvelopeDomain is the domain string used for peer records contained in a Envelope.
const PeerRecordEnvelopeDomain = "libp2p-peer-record" const PeerRecordEnvelopeDomain = "libp2p-peer-record"
// The type hint used to identify peer records in a Envelope. // PeerRecordEnvelopePayloadType is the type hint used to identify peer records in a Envelope.
// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv // Defined in https://github.com/multiformats/multicodec/blob/master/table.csv
// with name "libp2p-peer-record" // with name "libp2p-peer-record".
var PeerRecordEnvelopePayloadType = []byte{0x03, 0x01} var PeerRecordEnvelopePayloadType = []byte{0x03, 0x01}
// PeerRecord contains information that is broadly useful to share with other peers, // PeerRecord contains information that is broadly useful to share with other peers,

View File

@ -4,7 +4,7 @@ import (
"sync" "sync"
) )
// PeerSet is a threadsafe set of peers // PeerSet is a threadsafe set of peers.
type Set struct { type Set struct {
lk sync.RWMutex lk sync.RWMutex
ps map[ID]struct{} ps map[ID]struct{}

View File

@ -22,7 +22,7 @@ var (
// AddressTTL is the expiration time of addresses. // AddressTTL is the expiration time of addresses.
AddressTTL = time.Hour AddressTTL = time.Hour
// TempAddrTTL is the ttl used for a short lived address // TempAddrTTL is the ttl used for a short lived address.
TempAddrTTL = time.Minute * 2 TempAddrTTL = time.Minute * 2
// ProviderAddrTTL is the TTL of an address we've received from a provider. // ProviderAddrTTL is the TTL of an address we've received from a provider.
@ -115,10 +115,10 @@ type AddrBook interface {
// they will be sent along through the channel as well. // they will be sent along through the channel as well.
AddrStream(context.Context, peer.ID) <-chan ma.Multiaddr AddrStream(context.Context, peer.ID) <-chan ma.Multiaddr
// ClearAddresses removes all previously stored addresses // ClearAddresses removes all previously stored addresses.
ClearAddrs(p peer.ID) ClearAddrs(p peer.ID)
// PeersWithAddrs returns all of the peer IDs stored in the AddrBook // PeersWithAddrs returns all of the peer IDs stored in the AddrBook.
PeersWithAddrs() peer.IDSlice PeersWithAddrs() peer.IDSlice
} }
@ -159,7 +159,7 @@ type CertifiedAddrBook interface {
// //
// If the signed PeerRecord belongs to a peer that already has certified // If the signed PeerRecord belongs to a peer that already has certified
// addresses in the CertifiedAddrBook, the new addresses will replace the // addresses in the CertifiedAddrBook, the new addresses will replace the
// older ones, iff the new record has a higher sequence number than the // older ones, if the new record has a higher sequence number than the
// existing record. Attempting to add a peer record with a // existing record. Attempting to add a peer record with a
// sequence number that's <= an existing record for the same peer will not // sequence number that's <= an existing record for the same peer will not
// result in an error, but the record will be ignored, and the 'accepted' // result in an error, but the record will be ignored, and the 'accepted'
@ -227,7 +227,7 @@ type Metrics interface {
LatencyEWMA(peer.ID) time.Duration LatencyEWMA(peer.ID) time.Duration
} }
// ProtoBook tracks the protocols supported by peers // ProtoBook tracks the protocols supported by peers.
type ProtoBook interface { type ProtoBook interface {
GetProtocols(peer.ID) ([]string, error) GetProtocols(peer.ID) ([]string, error)
AddProtocols(peer.ID, ...string) error AddProtocols(peer.ID, ...string) error