Commit Graph

2344 Commits

Author SHA1 Message Date
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
e36d656632 log unusual event
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
Brian Tiger Chow
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
Brian Tiger Chow
6e7c46a6e2 unexport functions
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
Brian Tiger Chow
9c301a2d77 add comment
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
Brian Tiger Chow
1b1260b658 rm unused method
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
1d23e94f16 rm empty file
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:45 -08:00
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
39d71931a8 mv comment
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:44 -08:00
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
e11f099c42 privatize Task
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:44 -08:00
Brian Tiger Chow
181ff4eab1 tq.Cancel -> tq.Remove
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
460967839e doc: comment
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:43 -08:00
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
8c05c444a5 refactor: avoid loop reuse
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:42 -08:00
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
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
Brian Tiger Chow
5603b2e0a4 style: line wrapping
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:42 -08:00
Brian Tiger Chow
c0a18d9c08 fix(test): nil Blockstore
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:42 -08:00
Jeromy
69dd260236 refactor peerSet 2014-12-17 23:44:42 -08:00
Brian Tiger Chow
f533678724 avoid attaching context to object when it's not necessary.
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:42 -08:00
Brian Tiger Chow
f028c44fd2 name findOrCreate
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:41 -08:00
Brian Tiger Chow
1bced710b1 queue-like naming
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:41 -08:00
Brian Tiger Chow
29ef238fa3 remove dead code
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:41 -08:00
Brian Tiger Chow
86c438b6e1 refactor() message API
performing CR in the form of a PR. Let me know what you think.

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:41 -08:00
Jeromy
6389bfda6b some cleanup before CR 2014-12-17 23:44:41 -08:00
Jeromy
2240272d85 change Provide RPC to not wait for an ACK, improves performance of 'Add' operations 2014-12-17 23:44:41 -08:00
Jeromy
90a30961de renaming and removing empty strategy file 2014-12-17 23:44:41 -08:00
Jeromy
029e305f19 tasklist queue for bitswap tasks 2014-12-17 23:44:41 -08:00
Jeromy
cfbe92bc8b rewrite sendWantlistToProviders 2014-12-17 23:44:40 -08:00
Jeromy
946d2a96f2 add locks to wantlist to avoid race condition 2014-12-17 23:44:40 -08:00
Brian Tiger Chow
59f0ffb8c6 remove noisy statement
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:40 -08:00
Brian Tiger Chow
da68475bcf fix go version
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
2014-12-17 23:44:40 -08:00
Jeromy
50aa37fec4 blockstore.ErrNotFound, and proper wantlist sorting 2014-12-17 23:44:40 -08:00