@cryptotaxi247 / kubo / commits / 962a9477c

refactor: remove ledgerMap type

it's only used in two places, but i think we've been using maps on IPFS types so much now that the specificity is no longer necessary License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Dec 16, 2014 at 22:21 UTC 962a9477cc798af7b368e4b1bb1b510871b8c3e2
1 file changed +5 -8
exchange/bitswap/strategy/ledgermanager.go
+5 -8
@@ -3,8 +3,7 @@ package strategy
3 import (
4 "sync"
5
6 - "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
7 -
6 + context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
7 bstore "github.com/jbenet/go-ipfs/blocks/blockstore"
8 bsmsg "github.com/jbenet/go-ipfs/exchange/bitswap/message"
9 wl "github.com/jbenet/go-ipfs/exchange/bitswap/wantlist"
@@ -14,9 +13,6 @@ import (
13
14 var log = u.Logger("strategy")
15
17 -// LedgerMap lists Ledgers by their Partner key.
18 -type ledgerMap map[u.Key]*ledger
19 -
16 // Envelope contains a message for a Peer
17 type Envelope struct {
18 // Peer is the intended recipient
@@ -26,8 +22,9 @@ type Envelope struct {
22 }
23
24 type LedgerManager struct {
29 - lock sync.RWMutex
30 - ledgerMap ledgerMap
25 + lock sync.RWMutex
26 + // ledgerMap lists Ledgers by their Partner key.
27 + ledgerMap map[u.Key]*ledger
28 bs bstore.Blockstore
29 // FIXME taskqueue isn't threadsafe nor is it protected by a mutex. consider
30 // a way to avoid sharing the taskqueue between the worker and the receiver
@@ -38,7 +35,7 @@ type LedgerManager struct {
35
36 func NewLedgerManager(ctx context.Context, bs bstore.Blockstore) *LedgerManager {
37 lm := &LedgerManager{
41 - ledgerMap: make(ledgerMap),
38 + ledgerMap: make(map[u.Key]*ledger),
39 bs: bs,
40 taskqueue: newTaskQueue(),
41 outbox: make(chan Envelope, 4), // TODO extract constant