mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-03 13:00:37 +08:00
fix(bitswap:strategy) move key set
This commit is contained in:
@ -24,10 +24,6 @@ import (
|
|||||||
// advertisements. WantLists are sorted in terms of priority.
|
// advertisements. WantLists are sorted in terms of priority.
|
||||||
const PartnerWantListMax = 10
|
const PartnerWantListMax = 10
|
||||||
|
|
||||||
// KeySet is just a convenient alias for maps of keys, where we only care
|
|
||||||
// access/lookups.
|
|
||||||
type KeySet map[u.Key]struct{}
|
|
||||||
|
|
||||||
// bitswap instances implement the bitswap protocol.
|
// bitswap instances implement the bitswap protocol.
|
||||||
type bitswap struct {
|
type bitswap struct {
|
||||||
// peer is the identity of this (local) node.
|
// peer is the identity of this (local) node.
|
||||||
@ -59,6 +55,7 @@ func NewSession(parent context.Context, s bsnet.NetworkService, p *peer.Peer, d
|
|||||||
bs := &bitswap{
|
bs := &bitswap{
|
||||||
blockstore: blockstore.NewBlockstore(d),
|
blockstore: blockstore.NewBlockstore(d),
|
||||||
notifications: notifications.New(),
|
notifications: notifications.New(),
|
||||||
|
strategist: strategy.New(d),
|
||||||
peer: p,
|
peer: p,
|
||||||
routing: directory,
|
routing: directory,
|
||||||
sender: bsnet.NewNetworkAdapter(s, &receiver),
|
sender: bsnet.NewNetworkAdapter(s, &receiver),
|
||||||
|
@ -8,6 +8,10 @@ import (
|
|||||||
u "github.com/jbenet/go-ipfs/util"
|
u "github.com/jbenet/go-ipfs/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// keySet is just a convenient alias for maps of keys, where we only care
|
||||||
|
// access/lookups.
|
||||||
|
type keySet map[u.Key]struct{}
|
||||||
|
|
||||||
// ledger stores the data exchange relationship between two peers.
|
// ledger stores the data exchange relationship between two peers.
|
||||||
type ledger struct {
|
type ledger struct {
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
@ -28,7 +32,7 @@ type ledger struct {
|
|||||||
exchangeCount uint64
|
exchangeCount uint64
|
||||||
|
|
||||||
// wantList is a (bounded, small) set of keys that Partner desires.
|
// wantList is a (bounded, small) set of keys that Partner desires.
|
||||||
wantList KeySet
|
wantList keySet
|
||||||
|
|
||||||
Strategy strategyFunc
|
Strategy strategyFunc
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user