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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>