From 2ec1701494d710b9a63ba78979ca29b51eca61dd Mon Sep 17 00:00:00 2001 From: Jeromy Johnson Date: Thu, 24 Jul 2014 12:53:10 -0700 Subject: [PATCH] ledger and a util function on peerID --- bitswap/bitswap.go | 14 ++++++++++++-- peer/peer.go | 7 +++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bitswap/bitswap.go b/bitswap/bitswap.go index f457d47dc..cab466f98 100644 --- a/bitswap/bitswap.go +++ b/bitswap/bitswap.go @@ -2,13 +2,23 @@ package bitswap import ( "github.com/jbenet/go-ipfs/blocks" - "github.com/jbenet/go-multihash" + mh "github.com/jbenet/go-multihash" + + "time" ) // aliases type Ledger struct { - // todo + Owner mh.Multihash + + Partner mh.Multihash + + BytesSent uint64 + + BytesRecv uint64 + + Timestamp *time.Time } type BitSwap struct { diff --git a/peer/peer.go b/peer/peer.go index 856b23322..e7c3af2b4 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -4,11 +4,18 @@ import ( u "github.com/jbenet/go-ipfs/util" ma "github.com/jbenet/go-multiaddr" mh "github.com/jbenet/go-multihash" + + "bytes" ) // ID is a byte slice representing the identity of a peer. type ID mh.Multihash +// Utililty function for comparing two peer ID's +func (id *ID) Equal(other *ID) bool { + return bytes.Equal(*id, *other) +} + // Map maps Key (string) : *Peer (slices are not comparable). type Map map[u.Key]*Peer