1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 09:59:13 +08:00

2560 Commits

Author SHA1 Message Date
c84a714b16 peer change: peer.Peer -> peer.ID
this is a major refactor of the entire codebase
it changes the monolithic peer.Peer into using
a peer.ID and a peer.Peerstore.

Other changes:
- removed handshake3.
-	testutil vastly simplified peer
-	secio bugfix + debugging logs
-	testutil: RandKeyPair
-	backpressure bugfix: w.o.w.
-	peer: added hex enc/dec
-	peer: added a PeerInfo struct
  PeerInfo is a small struct used to pass around a peer with
 	a set of addresses and keys. This is not meant to be a
 	complete view of the system, but rather to model updates to
 	the peerstore. It is used by things like the routing system.
-	updated peer/queue + peerset
-	latency metrics
-	testutil: use crand for PeerID gen
 	RandPeerID generates random "valid" peer IDs. it does not
 	NEED to generate keys because it is as if we lost the key
 	right away. fine to read some randomness and hash it. to
 	generate proper keys and an ID, use:
 	  sk, pk, _ := testutil.RandKeyPair()
 	  id, _ := peer.IDFromPublicKey(pk)
 	Also added RandPeerIDFatal helper
- removed old spipe
- updated seccat
- core: cleanup initIdentity
- removed old getFromPeerList
2014-12-23 08:33:32 -08:00
d399a932fe peer/queue/sync: remove buffering 2014-12-23 08:32:53 -08:00
ec96a0b0b5 util: fractional context 2014-12-23 08:27:53 -08:00
cc7a869e3d threadsafe SeededRand 2014-12-23 08:26:24 -08:00
6e9cb06be3 Merge pull request #464 from chriscool/update_go_msgio_in_godeps
Godeps: update dependency for go-msgio
2014-12-21 02:04:41 -05:00
36b2cdb25b Godeps: update dependency for go-msgio
Otherwise there is the following failure when running godep restore:

fatal: reference is not a tree: 281b085dc602c4f0377438e20331f45a91bcdf9c
godep: restore: exit status 128

License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2014-12-20 20:47:52 +01:00
35e2338d65 update installation instructions and update usage to most recent 2014-12-19 19:25:19 +00:00
afd6680208 Merge pull request #438 from jbenet/bitswap-rounds
Bitswap rounds
2014-12-17 23:50:29 -08:00
9fafec1256 do not run epic tests in parallel
@whyrusleeping

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:46 -08:00
9328fbaf81 clean peerset constructor names 2014-12-17 23:44:46 -08:00
8100582e38 fix: batches of blocks have equal priority
addresses...

https://github.com/jbenet/go-ipfs/pull/438/files#r21878994

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:46 -08:00
bd3ee739b9 doc: some comments about the future of the decision engine
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:46 -08:00
ce2d0a2258 fix: add lock to taskQueue
@whyrusleeping may wanna have a look and make sure i didn't screw
anything up here

BenchmarkInstantaneousAddCat1MB-4            200          10763761 ns/op
97.42 MB/s
BenchmarkInstantaneousAddCat2MB-4       panic: runtime error: invalid
memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0xbedd]

goroutine 14297 [running]:
github.com/jbenet/go-ipfs/exchange/bitswap/decision.(*taskQueue).Remove(0xc2087553a0,
        0xc2085ef200, 0x22, 0x56f570, 0xc208367a40)
    /Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/decision/taskqueue.go:66
    +0x82
github.com/jbenet/go-ipfs/exchange/bitswap/decision.(*Engine).MessageSent(0xc20871b5c0,
        0x56f570, 0xc208367a40, 0x570040, 0xc208753d40, 0x0, 0x0)
    /Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/decision/engine.go:177
    +0x29e
github.com/jbenet/go-ipfs/exchange/bitswap.(*bitswap).send(0xc20871b7a0,
        0x56f4d8, 0xc208379800, 0x56f570, 0xc208367a40,
        0x570040, 0xc208753d40, 0x0, 0x0)
    /Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/bitswap.go:352
    +0x11c
github.com/jbenet/go-ipfs/exchange/bitswap.(*bitswap).taskWorker(0xc20871b7a0,
        0x56f4d8, 0xc208379800)
    /Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/bitswap.go:238
    +0x165
    created by
    github.com/jbenet/go-ipfs/exchange/bitswap.New
    /Users/btc/go/src/github.com/jbenet/go-ipfs/exchange/bitswap/bitswap.go:66
    +0x49e
2014-12-17 23:44:46 -08:00
175513e281 refactor(bs/decision.Engine): pass in Entry
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:46 -08:00
4bcfe094a1 extract constants
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:46 -08:00
0545c4d15d refactor: *Entry -> Entry
in many places, entries are assigned from one slice to another and in
different goroutines. In one place, entries were modified (in the
queue). To avoid shared mutable state, probably best to handle entries
by value.

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:46 -08:00
19764880d8 doc: peerset fixme
not changing this because i don't want to write a test for it now

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:46 -08:00
45faa4d7a0 fix: set peerset size
addresses https://github.com/jbenet/go-ipfs/pull/438#discussion_r21952271

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
e36d656632 log unusual event
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
2b60b641c4 fix: check blockstore before adding task
addresses https://github.com/jbenet/go-ipfs/pull/438#discussion_r21953742

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
6e7c46a6e2 unexport functions
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
9c301a2d77 add comment
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
1b1260b658 rm unused method
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
8d4d5b86ef fix: don't sort the output of Entries()
only sort SortedEntries()

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
acc714823b rename to peerRequestQueue
this opens up the possibility of having multiple queues. And for all
outgoing messages to be managed by the decision engine

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
1d23e94f16 rm empty file
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
5bd0b95462 rename to strategy.LedgerManager to decision.Engine
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:44 -08:00
bef622222d refactor: wantlist splits into WL and ThreadSafe WL
bitswap keeps the threadsafe version. observing the ledger shows that it
doesn't need it anymore (ledgermanager is protected and safe).

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:44 -08:00
d069ae11f4 refactor: put mutex next to the things it protects
If we put the lock next to the fields it protects, it can sometimes make
it easier to reason about threadsafety.

In this case, it reveals that the task queue (not threadsafe) isn't protected by the
mutex, yet shared between the worker and callers.

@whyrusleeping

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:44 -08:00
962a9477cc 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>
2014-12-17 23:44:44 -08:00
39d71931a8 mv comment
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:44 -08:00
7fdbae1306 refactor: separate responsibilties
Before, priority carried two pieces of information.

One: priority as defined by remote peer
Two: whether task is trashed

This assumes the protocol is defined for natural numbers instead of
integers. That may not always be the case. Better to leave that
assumption outside so this package isn't coupled to the whims of the
protocol.

The protocol may be changed to allow any integer value to be used.
Hopefully by that time, new responsibilties weren't added to the
Priority variable.

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:44 -08:00
fedcebf67a refactor: re-use wantlist.Entry type wherever it makes sense
it seems to make sense since, in each place, the Key and Priority
represent the same information

b/c you know the saying...

"It is better to have 100 functions operate on one data structure than
10 functions on 10 data structures."

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:44 -08:00
1d715956f5 doc: add comment to Envelope
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:44 -08:00
e11f099c42 privatize Task
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:44 -08:00
181ff4eab1 tq.Cancel -> tq.Remove
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
198aa1959a it's not a queue yet but it's okay to name it as such
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
7280aac83f perf: avoid lots of communication by signaling once at end of method
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
cc2a7312a2 add comment to fix race
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
b41fef2fff refactor: remove peerKey type
we've been using maps with peers long enough now that this probably is
no longer necessary

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
286723d888 unexport task and taskList
the less bitswap has to know about, the easier it'll be for readers.
(This now returns Messages.)

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
93fde86d18 refactor: taskKey := p.Key() + block.Key()
for clarity and to avoid errors, define a function

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
460967839e doc: comment
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
10e970c0cf refactor: context first in argument list
(merely by convention)

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
f66d94aaf1 fix: move the check into the function.
function should be a no-op when passed an empty slice

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:42 -08:00
8c05c444a5 refactor: avoid loop reuse
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:42 -08:00
2ea8ed81ac refactor: change Tasks to Outbox
notice that moving the blockstore fetch into the manager removes the
weird error handling case.

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:42 -08:00
a495a014af style constify variables
good to const until it's required for them to be variable.

TODO pass them in as configuration options
2014-12-17 23:44:42 -08:00
8bef1dce80 fix: move to callsite so public callers don't experience the internal timeout rule
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:42 -08:00
5603b2e0a4 style: line wrapping
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:42 -08:00