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>
style constify variables

good to const until it's required for them to be variable.

TODO pass them in as configuration options
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>
refactor: avoid  loop reuse

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
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>
refactor: context first in argument list

(merely by convention)

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
doc: comment

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
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>
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>
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>
add comment to fix race

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
perf: avoid lots of communication by signaling once at end of method

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
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>
tq.Cancel -> tq.Remove

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
privatize Task

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
doc: add comment to Envelope

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
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>
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>
mv comment

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
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>