mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-18 03:10:41 +08:00
ledger and a util function on peerID
This commit is contained in:
@ -2,13 +2,23 @@ package bitswap
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jbenet/go-ipfs/blocks"
|
"github.com/jbenet/go-ipfs/blocks"
|
||||||
"github.com/jbenet/go-multihash"
|
mh "github.com/jbenet/go-multihash"
|
||||||
|
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// aliases
|
// aliases
|
||||||
|
|
||||||
type Ledger struct {
|
type Ledger struct {
|
||||||
// todo
|
Owner mh.Multihash
|
||||||
|
|
||||||
|
Partner mh.Multihash
|
||||||
|
|
||||||
|
BytesSent uint64
|
||||||
|
|
||||||
|
BytesRecv uint64
|
||||||
|
|
||||||
|
Timestamp *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type BitSwap struct {
|
type BitSwap struct {
|
||||||
|
@ -4,11 +4,18 @@ import (
|
|||||||
u "github.com/jbenet/go-ipfs/util"
|
u "github.com/jbenet/go-ipfs/util"
|
||||||
ma "github.com/jbenet/go-multiaddr"
|
ma "github.com/jbenet/go-multiaddr"
|
||||||
mh "github.com/jbenet/go-multihash"
|
mh "github.com/jbenet/go-multihash"
|
||||||
|
|
||||||
|
"bytes"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ID is a byte slice representing the identity of a peer.
|
// ID is a byte slice representing the identity of a peer.
|
||||||
type ID mh.Multihash
|
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).
|
// Map maps Key (string) : *Peer (slices are not comparable).
|
||||||
type Map map[u.Key]*Peer
|
type Map map[u.Key]*Peer
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user