From 3f97e7e385d3e9f4e3350b1a557b549b78581260 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet <juan@benet.ai> Date: Tue, 22 Jul 2014 02:28:25 -0700 Subject: [PATCH] goling: PeerId -> ID --- bitswap/bitswap.go | 4 ++-- config/config.go | 2 +- core/core.go | 6 +++--- peer/peer.go | 16 ++++++++-------- peer/peer_test.go | 2 +- swarm/conn.go | 2 +- swarm/conn_test.go | 2 +- util/util_test.go | 1 - 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/bitswap/bitswap.go b/bitswap/bitswap.go index fc236936c..44e0c393c 100644 --- a/bitswap/bitswap.go +++ b/bitswap/bitswap.go @@ -1,7 +1,7 @@ package bitswap import ( - "github.com/jbenet/go-ipfs/peer" + peer "github.com/jbenet/go-ipfs/peer" ) // aliases @@ -11,7 +11,7 @@ type Ledger struct { } type BitSwap struct { - Ledgers map[peer.PeerId]*Ledger + Ledgers map[peer.ID]*Ledger HaveList map[multihash.Multihash]*block.Block WantList []*multihash.Multihash } diff --git a/config/config.go b/config/config.go index f1ae627d1..664eeeee5 100644 --- a/config/config.go +++ b/config/config.go @@ -7,7 +7,7 @@ import ( // Identity tracks the configuration of the local node's identity. type Identity struct { - PeerId string + PeerID string } // Datastore tracks the configuration of the datastore. diff --git a/core/core.go b/core/core.go index bd22ff9f2..66058cf61 100644 --- a/core/core.go +++ b/core/core.go @@ -19,8 +19,8 @@ type IpfsNode struct { // the local node's identity Identity *peer.Peer - // the book of other nodes (a map of Peer instances) - PeerBook *peer.PeerBook + // the map of other nodes (Peer instances) + PeerMap *peer.Map // the local datastore Datastore ds.Datastore @@ -67,7 +67,7 @@ func NewIpfsNode(cfg *config.Config) (*IpfsNode, error) { n := &IpfsNode{ Config: cfg, - PeerBook: &peer.PeerBook{}, + PeerMap: &peer.Map{}, Datastore: d, Blocks: bs, DAG: dag, diff --git a/peer/peer.go b/peer/peer.go index 96e0aba80..856b23322 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -6,22 +6,22 @@ import ( mh "github.com/jbenet/go-multihash" ) -// PeerId is a byte slice representing the identity of a peer. -type PeerId mh.Multihash +// ID is a byte slice representing the identity of a peer. +type ID mh.Multihash -// PeerBook maps Key (string) : *Peer (slices are not comparable). -type PeerBook map[u.Key]*Peer +// Map maps Key (string) : *Peer (slices are not comparable). +type Map map[u.Key]*Peer // Peer represents the identity information of an IPFS Node, including -// a PeerId, and relevant Addresses. +// ID, and relevant Addresses. type Peer struct { - Id PeerId + ID ID Addresses []*ma.Multiaddr } -// Key returns the PeerId as a Key (string) for maps. +// Key returns the ID as a Key (string) for maps. func (p *Peer) Key() u.Key { - return u.Key(p.Id) + return u.Key(p.ID) } // AddAddress adds the given Multiaddr address to Peer's addresses. diff --git a/peer/peer_test.go b/peer/peer_test.go index 41ccf8310..133acc221 100644 --- a/peer/peer_test.go +++ b/peer/peer_test.go @@ -26,7 +26,7 @@ func TestNetAddress(t *testing.T) { return } - p := Peer{Id: PeerId(mh)} + p := Peer{ID: ID(mh)} p.AddAddress(tcp) p.AddAddress(udp) diff --git a/swarm/conn.go b/swarm/conn.go index 23938555c..a24a5e7ad 100644 --- a/swarm/conn.go +++ b/swarm/conn.go @@ -23,7 +23,7 @@ type Conn struct { Incoming *msgio.Chan } -// ConnMap maps Keys (PeerIds) to Connections. +// ConnMap maps Keys (Peer.IDs) to Connections. type ConnMap map[u.Key]*Conn // Dial connects to a particular peer, over a given network diff --git a/swarm/conn_test.go b/swarm/conn_test.go index f53a202ac..171d9c38b 100644 --- a/swarm/conn_test.go +++ b/swarm/conn_test.go @@ -20,7 +20,7 @@ func setupPeer(id string, addr string) (*peer.Peer, error) { return nil, err } - p := &peer.Peer{Id: peer.PeerId(mh)} + p := &peer.Peer{ID: peer.ID(mh)} p.AddAddress(tcp) return p, nil } diff --git a/util/util_test.go b/util/util_test.go index 7341fdc20..6a269dbb5 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -2,7 +2,6 @@ package util import ( "bytes" - "fmt" mh "github.com/jbenet/go-multihash" "testing" ) -- GitLab