Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-core
Commits
43f10f22
Commit
43f10f22
authored
Mar 03, 2020
by
Vasco Santos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: uniform comment sentences
parent
ee957399
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
20 deletions
+20
-20
connmgr/connmgr.go
connmgr/connmgr.go
+1
-1
peer/addrinfo.go
peer/addrinfo.go
+1
-1
peer/peer.go
peer/peer.go
+3
-3
peer/peer_serde.go
peer/peer_serde.go
+6
-6
peer/record.go
peer/record.go
+3
-3
peer/set.go
peer/set.go
+1
-1
peerstore/peerstore.go
peerstore/peerstore.go
+5
-5
No files found.
connmgr/connmgr.go
View file @
43f10f22
...
...
@@ -61,7 +61,7 @@ type ConnManager interface {
// See notes on Protect() for more info.
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
}
...
...
peer/addrinfo.go
View file @
43f10f22
...
...
@@ -74,7 +74,7 @@ func AddrInfoFromP2pAddr(m ma.Multiaddr) (*AddrInfo, error) {
return
info
,
nil
}
// AddrInfoToP2pAddr converts an AddrInfo to a list of Multiaddrs.
// AddrInfoToP2pAddr
s
converts an AddrInfo to a list of Multiaddrs.
func
AddrInfoToP2pAddrs
(
pi
*
AddrInfo
)
([]
ma
.
Multiaddr
,
error
)
{
var
addrs
[]
ma
.
Multiaddr
p2ppart
,
err
:=
ma
.
NewComponent
(
"p2p"
,
IDB58Encode
(
pi
.
ID
))
...
...
peer/peer.go
View file @
43f10f22
...
...
@@ -57,7 +57,7 @@ func (id ID) String() string {
return
id
.
Pretty
()
}
// String prints out the peer ID.
//
Short
String prints out the peer ID.
//
// TODO(brian): ensure correctness at ID generation and
// enforce this by only exposing functions that generate
...
...
@@ -85,7 +85,7 @@ func (id ID) MatchesPublicKey(pk ic.PubKey) bool {
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
// the public key.
...
...
@@ -237,7 +237,7 @@ func IDFromPrivateKey(sk ic.PrivKey) (ID, error) {
return
IDFromPublicKey
(
sk
.
GetPublic
())
}
// IDSlice for sorting peers
// IDSlice for sorting peers
.
type
IDSlice
[]
ID
func
(
es
IDSlice
)
Len
()
int
{
return
len
(
es
)
}
...
...
peer/peer_serde.go
View file @
43f10f22
//
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
import
(
...
...
@@ -21,7 +21,7 @@ func (id ID) Marshal() ([]byte, error) {
return
[]
byte
(
id
),
nil
}
//
Binary
Marshal returns the byte representation of the peer ID.
// Marshal
Binary
returns the byte representation of the peer ID.
func
(
id
ID
)
MarshalBinary
()
([]
byte
,
error
)
{
return
id
.
Marshal
()
}
...
...
@@ -35,12 +35,12 @@ func (id *ID) Unmarshal(data []byte) (err error) {
return
err
}
//
Binary
Unmarshal sets the ID from its binary representation.
// Unmarshal
Binary
sets the ID from its binary representation.
func
(
id
*
ID
)
UnmarshalBinary
(
data
[]
byte
)
error
{
return
id
.
Unmarshal
(
data
)
}
//
I
mplements Gogo's proto.Sizer, but we omit the compile-time assertion to avoid introducing a hard
//
Size i
mplements Gogo's proto.Sizer, but we omit the compile-time assertion to avoid introducing a hard
// dependency on gogo.
func
(
id
ID
)
Size
()
int
{
return
len
([]
byte
(
id
))
...
...
@@ -59,12 +59,12 @@ func (id *ID) UnmarshalJSON(data []byte) (err error) {
return
err
}
//
Text
Marshal returns the text encoding of the ID.
// Marshal
Text
returns the text encoding of the ID.
func
(
id
ID
)
MarshalText
()
([]
byte
,
error
)
{
return
[]
byte
(
IDB58Encode
(
id
)),
nil
}
//
Text
Unmarshal restores the ID from its text encoding.
// Unmarshal
Text
restores the ID from its text encoding.
func
(
id
*
ID
)
UnmarshalText
(
data
[]
byte
)
error
{
pid
,
err
:=
IDB58Decode
(
string
(
data
))
if
err
!=
nil
{
...
...
peer/record.go
View file @
43f10f22
...
...
@@ -18,12 +18,12 @@ func init() {
record
.
RegisterType
(
&
PeerRecord
{})
}
//
T
he domain string used for peer records contained in a Envelope.
//
PeerRecordEnvelopeDomain is t
he domain string used for peer records contained in a Envelope.
const
PeerRecordEnvelopeDomain
=
"libp2p-peer-record"
//
T
he type hint used to identify peer records in a Envelope.
//
PeerRecordEnvelopePayloadType is t
he type hint used to identify peer records in a Envelope.
// 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
}
// PeerRecord contains information that is broadly useful to share with other peers,
...
...
peer/set.go
View file @
43f10f22
...
...
@@ -4,7 +4,7 @@ import (
"sync"
)
// PeerSet is a threadsafe set of peers
// PeerSet is a threadsafe set of peers
.
type
Set
struct
{
lk
sync
.
RWMutex
ps
map
[
ID
]
struct
{}
...
...
peerstore/peerstore.go
View file @
43f10f22
...
...
@@ -22,7 +22,7 @@ var (
// AddressTTL is the expiration time of addresses.
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
// 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.
AddrStream
(
context
.
Context
,
peer
.
ID
)
<-
chan
ma
.
Multiaddr
// ClearAddresses removes all previously stored addresses
// ClearAddresses removes all previously stored addresses
.
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
}
...
...
@@ -159,7 +159,7 @@ type CertifiedAddrBook interface {
//
// If the signed PeerRecord belongs to a peer that already has certified
// addresses in the CertifiedAddrBook, the new addresses will replace the
// older ones, if
f
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
// 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'
...
...
@@ -227,7 +227,7 @@ type Metrics interface {
LatencyEWMA
(
peer
.
ID
)
time
.
Duration
}
// ProtoBook tracks the protocols supported by peers
// ProtoBook tracks the protocols supported by peers
.
type
ProtoBook
interface
{
GetProtocols
(
peer
.
ID
)
([]
string
,
error
)
AddProtocols
(
peer
.
ID
,
...
string
)
error
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment