Commit Graph

346 Commits

Author SHA1 Message Date
Brian Tiger Chow
83716af890 fix(bitswap) shut down async 2014-11-05 10:13:24 -08:00
Brian Tiger Chow
40c5cca117 fix(bitswap) always cancel on return 2014-11-05 10:04:20 -08:00
Brian Tiger Chow
a529378ce0 fix(bitswap) don't 'go' local function calls 2014-11-05 10:04:20 -08:00
Brian Tiger Chow
23096de3c4 fix(net) pass contexts to dial peer 2014-11-05 10:04:20 -08:00
Brian Tiger Chow
c60d011764 fix(exchange) add context to DialPeer 2014-11-05 10:04:20 -08:00
Brian Tiger Chow
45b1929342 fix(bitswap_test) race cond
https://github.com/jbenet/go-ipfs/issues/270#issuecomment-61826022
2014-11-05 10:01:22 -08:00
Brian Tiger Chow
49ac059c37 docs: TODO 2014-11-02 20:40:25 -08:00
Jeromy
317ca2f865 benchmark secure channel 2014-11-01 16:07:56 -07:00
Brian Tiger Chow
42dfc50250 docs(bitswap/message) BitSwapMessage interface 2014-10-27 22:43:54 -07:00
Brian Tiger Chow
edf99f5e20 fix(bitswap) preserve ordering in bitswap message 2014-10-27 22:43:54 -07:00
Brian Tiger Chow
91a31a3e7d test(bitswap/message) no duplicates 2014-10-27 21:58:21 -07:00
Brian Tiger Chow
cebeff43b9 style(bitswap/message) rename method -> AddBlock
to emphasize idempotence
2014-10-27 21:58:21 -07:00
Brian Tiger Chow
caedb64697 fix(bitswap/message) impl with map to ensure no duplicate blocks
comes at the cost of O(n) Blocks() method.
2014-10-27 21:58:21 -07:00
Brian Tiger Chow
2c4fefb9d6 style(bitswap/message) rename struct
so there's one less name to think about
2014-10-27 21:58:20 -07:00
Brian Tiger Chow
f94d6a37b6 refactor(bitswap/message) use map to prevent duplicate entries
A nice invariant for bitswap sessions:

        Senders and receivers can trust that messages do not contain
        duplicate blocks or duplicate keys. Backing the message with a
        map enforces this invariant.

        This comes at the cost of O(n) getters.
2014-10-27 21:58:20 -07:00
Brian Tiger Chow
842b910853 style(bitswap/message) rename AppendWanted -> AddWanted
implementation will be patched to ensure bitswap messages cannot contain
duplicate blocks or keys
2014-10-27 21:58:20 -07:00
Brian Tiger Chow
8193049dda fix(bitswap) duplicate key in wantlist
@whyrusleeping noticed this a couple days ago

potential long-term fix: prevent duplicate entries in the wantlist by
using a map/set and iterating over this data structure on export
2014-10-27 21:58:20 -07:00
Jeromy
d92db12460 lots of logging 2014-10-26 00:45:40 +00:00
Jeromy
ab7491f809 logging, logging, and some minor logging 2014-10-25 14:50:22 -07:00
Jeromy
e1f2fe75f8 add in dag removal 2014-10-25 12:39:36 -07:00
Brian Tiger Chow
0dba976070 style(bitswap) import 2014-10-25 04:14:23 -07:00
Brian Tiger Chow
7f40a08b12 fix(bitswap) rm todo 2014-10-25 04:14:17 -07:00
Juan Batiz-Benet
184c25430b go-vet friendly codebase
- distinguish log.Error and log.Errorf functions
- Initialize structs with field names
- A bit of unreachable code (defers)
2014-10-25 03:46:39 -07:00
Brian Tiger Chow
c848202c7d fix(bitswap) move mutex up to strategy from ledger
addresses concurrent access in bitswap session
2014-10-24 16:17:15 -07:00
Brian Tiger Chow
715f5f4a19 fix(blockstore, bitswap) enforce threadsafety in blockstore
fixes data race detected in a testnet test
2014-10-24 16:16:41 -07:00
Brian Tiger Chow
80b573425b refactor(bitswap) mv proto PBMessage -> Message 2014-10-22 21:49:46 -07:00
Brian Tiger Chow
d3ac9ceee3 misc(exch/bitswap) add TODOs 2014-10-22 15:54:18 -07:00
Brian Tiger Chow
8823f46248 fix(exch/bs/pb) rename proto package -> bitswap_message_pb 2014-10-22 15:54:18 -07:00
Brian Tiger Chow
15605fb18f refactor(exchange/bitswap) move proto to internal pb package 2014-10-22 15:54:17 -07:00
Juan Batiz-Benet
f7c1ed39e0 renamed datastore.go -> go-datastore 2014-10-21 15:10:58 -07:00
Juan Batiz-Benet
9ca87fbb93 peer.Peer is now an interface
![](http://m.memegen.com/77n7dk.jpg)
2014-10-20 03:26:46 -07:00
Juan Batiz-Benet
c894b1d295 iiii -> peerToQuery
(that wasn't mine :p)
2014-10-18 04:28:24 -07:00
Juan Batiz-Benet
4b5906e466 logging + tweaks 2014-10-18 04:28:24 -07:00
Juan Batiz-Benet
a5a7d99860 meant to call net.DialPeer 2014-10-18 04:28:24 -07:00
Juan Batiz-Benet
1555ce7c48 bitswap dials peers
Important bugfix. Otherwise bitswap cannot message peers
the node has not connected to yet :(
2014-10-18 04:28:23 -07:00
Juan Batiz-Benet
338b037238 clean up and add inet.Network to bitswap
new Service interface
2014-10-10 20:43:04 -07:00
Juan Batiz-Benet
972c0f7b4b u.DOut -> log.Debug
and other logging switches. I kept the u.PErr and u.POut in cli
commands, as those do need to write raw output directly.
2014-10-09 04:50:22 -07:00
Juan Batiz-Benet
7c5679536c bugfix: use consistent interface
We'll want a `type blocks.Block interface {}` later, but
for now, make sure Blockstore uses ptrs for both Get and Put.

+ fix NewBlock output compile error
2014-10-07 21:32:17 -07:00
Jeromy
6e0cfb3273 removed error from return type of blocks.NewBlock() 2014-10-07 20:46:01 +00:00
Juan Batiz-Benet
77fccaa2f3 Obviated need for .ID.Pretty() all over the place. 2014-10-06 04:23:55 -07:00
Brian Tiger Chow
e2a9c5de00 feat(net:service, routing) remove error return value 2014-09-24 23:35:36 -04:00
Brian Tiger Chow
0e494690b3 feat(bitswap:network) propagate errors up the stack
Rather than pushing errors back down to lower layers, propagate the
errors upward.

This commit adds a `ReceiveError` method to BitSwap's network receiver.

Still TODO: rm the error return value from:

    net.service.handler.HandleMessage

This is inspired by delegation patterns in found in the wild.
2014-09-24 23:35:36 -04:00
Jeromy
c044d9c32e move mock routing tests to proper directory 2014-09-23 18:23:46 -04:00
Jeromy
414ff34194 change back to using Client method 2014-09-23 18:23:46 -04:00
Jeromy
c45cc8c448 implement a mock dht for use in testing 2014-09-23 18:23:46 -04:00
Brian Tiger Chow
b85d1554cc doc(bitswap:strat) add note to remove blocks from peer's wantlist after
sending
2014-09-22 04:06:19 -07:00
Brian Tiger Chow
9d7ae40003 feat(bitswap) expose ability to toggle "niceness"
true -> always send to peer

false -> use ledger-based strategy described in IPFS paper draft 3
2014-09-22 04:06:19 -07:00
Brian Tiger Chow
767d6ca633 refac(bitswap, util) extract KeySet 2014-09-22 04:06:19 -07:00
Brian Tiger Chow
faee10effe test(bitswap) send entire wantlist to peers
fix(bitswap) pass go vet

fixes #97

https://github.com/jbenet/go-ipfs/issues/97
2014-09-22 04:06:19 -07:00
Brian Tiger Chow
39ad222da9 fix(bitswap) keep interface the same
changing the bitswap interace breaks tests and makes things a bit
difficult going forward. I think I have a temporary solution to replace
the async method.

this commit partially reverts changes from:

ec50703395098f75946f0bad01816cc54ab18a58

ec50703395
2014-09-22 04:06:18 -07:00
Brian Tiger Chow
2179b5d77b fix(bitswap:testnet) Provide takes ctx 2014-09-22 04:06:18 -07:00
Brian Tiger Chow
b806270e5d test(bitswap) test sending wantlist to peers 2014-09-22 04:06:18 -07:00
Brian Tiger Chow
b4ef99bc81 fix(exch) name the error 2014-09-22 04:06:18 -07:00
Brian Tiger Chow
b5ea124a76 style(bitswap) swap argument order 2014-09-22 04:06:18 -07:00
Brian Tiger Chow
7d62be76ad chore(bitswap) cleanup 2014-09-22 04:06:18 -07:00
Brian Tiger Chow
60798b800a style(bitswap) make signature more readable 2014-09-22 04:06:18 -07:00
Juan Batiz-Benet
8112fae7b3 get bitswap working with dht
@perfmode using non-async version as apparently there's
a bug in async. will look into it.
2014-09-22 04:06:18 -07:00
Juan Batiz-Benet
52cefb16cd Routing uses context now
@perfmode boom
2014-09-22 04:06:18 -07:00
Brian Tiger Chow
315e121ef9 feat(bitswap:message) implement FromNet 2014-09-22 04:06:16 -07:00
Brian Tiger Chow
b7b046582b test(bitswap) test with swarm of ~500 instances
test(bitswap) run synchronously to aid the scheduler
2014-09-22 04:06:16 -07:00
Brian Tiger Chow
d0a5339547 feat(bitswap) ACTIVATE FULL CONCURRENCY cap'n
fix(bitswap) Put synchronously. Then notify async
2014-09-22 04:06:16 -07:00
Brian Tiger Chow
88f5be3f0d test(bitswap:testnet) shuffle the providers
to avoid letting client rely on order for correctness
2014-09-22 04:06:16 -07:00
Brian Tiger Chow
8213cfbaa4 docs(bitswap:strat) interface comments 2014-09-22 04:06:16 -07:00
Brian Tiger Chow
251f1d7f00 test(bitswap) add SessionGenerator 2014-09-22 04:06:16 -07:00
Brian Tiger Chow
5aa6ccbad5 refac(bitswap) nil slices are 'range'able 2014-09-22 04:06:16 -07:00
Brian Tiger Chow
331fcd1756 chore(bitswap) rm unused helper func 2014-09-22 04:06:16 -07:00
Brian Tiger Chow
a5fb64071a test(bitswap) enable get block test 2014-09-22 04:06:16 -07:00
Brian Tiger Chow
6e7a12dc11 refac(exch:offline) move offline exchange to its own package 2014-09-22 04:06:15 -07:00
Brian Tiger Chow
ddf889d876 test(bitswap) send block from one instance to another 2014-09-22 04:06:15 -07:00
Brian Tiger Chow
800af9ca3a fix(bitswap:message) don't use proto internally 2014-09-22 04:06:15 -07:00
Brian Tiger Chow
57e088bbff fix(bitswap:testnet) use peer.Map 2014-09-22 04:06:15 -07:00
Brian Tiger Chow
a8a7caa088 refac(bitswap:testnet) give testnet its own package 2014-09-22 04:06:15 -07:00
Brian Tiger Chow
9f685af14f test(bitswap) 2014-09-22 04:06:15 -07:00
Brian Tiger Chow
543dfeea35 refac(bitswap) less concurrency while testing and iterating 2014-09-22 04:06:15 -07:00
Brian Tiger Chow
6e1c3b36bb fix(bitswap) check for nil in public interface 2014-09-22 04:06:15 -07:00
Brian Tiger Chow
c80c8aa977 test(bitswap:testnet)
misc:
* test network client getting more than max
* test for find providers
* rename factory method
* local network
* misc test improvements
* test bitswap get block timeout
* test provider exists but cannot connect to peer
* test sending a message async over local network
2014-09-22 04:06:15 -07:00
Brian Tiger Chow
7975ffe721 fix(exchange) package name 2014-09-22 04:06:15 -07:00
Brian Tiger Chow
0c67019447 style(exch:bitswap) rename adapter, session, etc.
style(exch:bitswap) rename NetMessage adapter impl
2014-09-22 04:06:14 -07:00
Brian Tiger Chow
071a66495f style(exch:bitswap) rename variable 2014-09-22 04:06:14 -07:00
Brian Tiger Chow
71aed67413 feat(bitswap) broadcast block to routing, peers on receipt 2014-09-22 04:06:14 -07:00
Brian Tiger Chow
98a6e9fac2 feat(exch:bitswap) simply get method 2014-09-22 04:06:14 -07:00
Brian Tiger Chow
74e81e06fa refac(bitswap) extract const 2014-09-22 04:06:14 -07:00
Brian Tiger Chow
9a18fd6354 chore(exch, bitswap) misc trivial cleanup 2014-09-22 04:06:14 -07:00
Brian Tiger Chow
e907b2e03c feat(exchange) pass ctx to exchange.HasBlock(...) 2014-09-22 04:06:14 -07:00
Brian Tiger Chow
1054b8d8ad fix(bitswap) use passed ctx 2014-09-22 04:06:14 -07:00
Brian Tiger Chow
42770cc39a refac(exchange) replace timeout -> context in API 2014-09-22 04:06:14 -07:00
Brian Tiger Chow
252be07ec5 refac(bitswap) let adapter be created with nil delegate
yay deleting code.
2014-09-22 04:06:14 -07:00
Brian Tiger Chow
0bd8f2092b refac(routing) replace timeout -> ctx
@jbenet oh hai there!
2014-09-22 04:06:14 -07:00
Brian Tiger Chow
81da645ed6 chore(bitswap) remove unused const 2014-09-22 04:06:14 -07:00
Brian Tiger Chow
85f84fe446 refac(ex:bs) remove local peer ref until shown to be necessary 2014-09-22 04:06:13 -07:00
Brian Tiger Chow
d82a2517d1 refac(exch:bitswap) always notify strategy when message sent 2014-09-22 04:06:13 -07:00
Brian Tiger Chow
335b50f4c6 style(ex:bitswap) put public methods at top 2014-09-22 04:06:13 -07:00
Brian Tiger Chow
5cec6197ae test(exch:bs:strategy) test accounting consistency
> Why expose num bytes sent and received?

    Makes it easy to test consistency of the ledgers

> Got a better reason?

    Makes it possible to expose metrics to the people-facing API
2014-09-22 04:06:13 -07:00
Brian Tiger Chow
ded1f8f5a8 fix(bitswap) compiler errors
didn't run tests after the refactor. apologies.
2014-09-22 04:06:13 -07:00
Brian Tiger Chow
e1fe4f6d60 refac(exchange) rename exchange.Interface to match golang conventions
examples:

    http://golang.org/pkg/container/heap/#Interface

    http://golang.org/pkg/net/#Interface

    http://golang.org/pkg/sort/#Interface
2014-09-22 04:06:13 -07:00
Brian Tiger Chow
fd086b9c48 refac(exchange) bitswap -> exchange/bitswap
Move go-ipfs/bitswap package to go-ipfs/exchange/bitswap

* Delineates the difference between the generic exchange interface and
  implementations (eg. BitSwap protocol)

  Thus, the bitswap protocol can be refined without having to overthink
  how future exchanges will work. Aspects common to BitSwap and other
  exchanges can be extracted out to the exchange package in piecemeal.

  Future exchange implementations can be placed in sibling packages next
  to exchange/bitswap. (eg. exchange/multilateral)
2014-09-22 04:06:13 -07:00