Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate go-bitswap #63

Merged
merged 1,208 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1208 commits
Select commit Hold shift + click to select a range
efada36
fix: overly aggressive session peer removal
dirkmc Mar 5, 2020
0b89a15
Disable flaky benchmark
dirkmc Mar 5, 2020
20d9754
fix: block receive shouldn't affect DONT_HAVE count for other peers
dirkmc Mar 6, 2020
5b47aaf
refactor: avoid unnecessary go-routine
dirkmc Mar 6, 2020
78db333
Merge branch 'fix/prune-dont-have' of https://github.com/ipfs/go-bits…
dirkmc Mar 6, 2020
277806a
fix: flaky test
dirkmc Mar 6, 2020
e8e5dff
test: fix another flaky test
dirkmc Mar 6, 2020
eec7ee9
fix: flaky test
dirkmc Mar 6, 2020
d939c9f
Merge pull request ipfs/go-bitswap#276 from ipfs/fix/prune-dont-have
Stebalien Mar 6, 2020
ee5ef3d
feat: timeout when peer doesnt respond to want-block
dirkmc Mar 10, 2020
c863614
docs: fix find peers log level
dirkmc Mar 10, 2020
4cfa0ab
fix: flaky provider query manager (#286)
dirkmc Mar 10, 2020
cfd5219
fix: flaky engine peer tagging test (#287)
dirkmc Mar 10, 2020
a1ea260
Merge pull request ipfs/go-bitswap#284 from ipfs/feat/dont-have-new-p…
Stebalien Mar 10, 2020
e990eab
fix: re-export testinstance/testnet
Stebalien Mar 11, 2020
6076f1e
Merge pull request ipfs/go-bitswap#289 from ipfs/fix/re-export-testing
Stebalien Mar 11, 2020
c797006
fix: flaky TestDontHaveTimeoutMgrTimeout
dirkmc Mar 11, 2020
0ced6db
Merge pull request ipfs/go-bitswap#293 from ipfs/fix/flaky-test-TestD…
Stebalien Mar 11, 2020
aa3c108
fix: order of session broadcast wants
dirkmc Mar 11, 2020
42d1010
refactor: improve sessionWants perf
dirkmc Mar 12, 2020
ec90079
fix: flaky TestRateLimitingRequests
dirkmc Mar 12, 2020
48f6082
Merge pull request ipfs/go-bitswap#296 from ipfs/fix/test-TestRateLim…
Stebalien Mar 12, 2020
53e16ad
fix: engine test TestTaggingUseful (#297)
dirkmc Mar 12, 2020
0534f69
Merge pull request ipfs/go-bitswap#291 from ipfs/fix/session-broadcas…
Stebalien Mar 12, 2020
3c5c056
refactor: clean up logs
dirkmc Mar 13, 2020
a49dd71
refactor: adjust log levels
dirkmc Mar 16, 2020
e58d776
Merge pull request ipfs/go-bitswap#299 from ipfs/refactor/log-cleanup
Stebalien Mar 16, 2020
202651a
feat: expose the full wantlist through GetWantlist
Stebalien Mar 14, 2020
a50f325
Merge pull request ipfs/go-bitswap#300 from ipfs/feat/full-wantlist
Stebalien Mar 16, 2020
385475d
feat: remove the context from the donthavetimeoutmanager (#303)
Stebalien Mar 17, 2020
202a263
fix: 64bit align stats (#305)
Stebalien Mar 17, 2020
d0b22fe
feat: micro-optimize priority (#304)
Stebalien Mar 17, 2020
0a2e7b5
feat: add a custom CID type
Stebalien Mar 18, 2020
ea674aa
Merge pull request ipfs/go-bitswap#308 from ipfs/feat/custom-cid-type
Stebalien Mar 19, 2020
762d2dd
test(message): test custom CID type (#309)
Stebalien Mar 19, 2020
bd22c61
perf: add message queue benchmark
dirkmc Mar 18, 2020
174d666
perf: improve extractOutgoingMessage() performance
dirkmc Mar 18, 2020
ebe9e03
fix: race in tests
dirkmc Mar 19, 2020
d6d8d03
refactor: reuse message queue message for perf
dirkmc Mar 19, 2020
3a8adc9
fix: virtual net race
dirkmc Mar 19, 2020
5f5181a
refactor: small changes to message queue
dirkmc Mar 19, 2020
d3c082a
Merge pull request ipfs/go-bitswap#307 from ipfs/perf/message-queue
Stebalien Mar 19, 2020
630eed9
fix: wait for sessionWantSender to shutdown before completing session…
dirkmc Mar 24, 2020
dba1971
fix: flaky TestDontHaveTimeoutMgrTimeout (#320)
dirkmc Mar 24, 2020
1bd3344
fix: flaky TestSendDontHave (#321)
dirkmc Mar 24, 2020
876dc3c
fix: flaky TestSendsWantBlockToOnePeerOnly (#323)
dirkmc Mar 24, 2020
05c0d05
refactor: simplify sessionWantSender shutdown
dirkmc Mar 24, 2020
aa5d143
refactor: use internal context in sessionWantSender
dirkmc Mar 24, 2020
3da9ff1
Merge pull request ipfs/go-bitswap#317 from ipfs/fix/sesswantmgr-shut…
Stebalien Mar 24, 2020
be36301
chore: make pwm internals private (#315)
Stebalien Mar 24, 2020
901a508
fix: log unexpected condition in peerWantManager.prepareSendWants()
dirkmc Mar 24, 2020
9d3ada9
Merge pull request ipfs/go-bitswap#325 from ipfs/fix/pmgr-log
Stebalien Mar 24, 2020
feabf10
fix: race in SessionInterestManager (#324)
dirkmc Mar 24, 2020
5fe4612
chore: address todo in engine.go
Stebalien Mar 26, 2020
9cfa597
fix: avoid copying messages multiple times on send
Stebalien Mar 26, 2020
d438a94
feat: normalize message logging
Stebalien Mar 26, 2020
41b924e
Merge pull request ipfs/go-bitswap#326 from ipfs/feat/faster-send-blocks
Stebalien Mar 26, 2020
d18c4c0
fix: ensure wantlist gauge gets decremented on disconnect
dirkmc Apr 3, 2020
6c9f559
Merge pull request ipfs/go-bitswap#332 from ipfs/fix/wantlist-gauge
Stebalien Apr 3, 2020
f73dc9b
Add separate how bitswap works doc (#294)
dirkmc Apr 7, 2020
dd4205b
fix: path to architecture diagram (#338)
dirkmc Apr 7, 2020
cf0893f
fix: start score worker along with other engine workers (#344)
Stebalien Apr 10, 2020
378f7df
fix: in message queue only send cancel if want was sent
dirkmc Apr 10, 2020
f610dcf
Merge pull request ipfs/go-bitswap#345 from ipfs/fix/cancel-leak
Stebalien Apr 11, 2020
9432df5
feat: prioritize more important wants
Stebalien Apr 11, 2020
2fb1ad8
Merge pull request ipfs/go-bitswap#346 from ipfs/feat/prioritize-wants
Stebalien Apr 11, 2020
a1b6ce9
fix: avoid allocating cids (#348)
Stebalien Apr 13, 2020
12d4fe8
refactor: simplify messageQueue onSent
dirkmc Apr 13, 2020
0b4f1f7
refactor: save some vars
dirkmc Apr 13, 2020
d1da580
refactor: remove unnecessary func param
dirkmc Apr 13, 2020
d0710f4
fix: only mark sent wants as sent
dirkmc Apr 13, 2020
6065241
Merge pull request ipfs/go-bitswap#349 from ipfs/refactor/simplify-mq…
Stebalien Apr 13, 2020
50c92d6
feat: optimize message sending (#350)
Stebalien Apr 14, 2020
0bc278a
refactor: move connection management into networking layer
dirkmc Apr 15, 2020
9ad62e8
fix: stop sender when message queue shut down
dirkmc Apr 15, 2020
5183004
fix: tests
dirkmc Apr 15, 2020
eb1ae9c
fix: don't hang on to disconnected peer refs
dirkmc Apr 16, 2020
4429610
fix: shutdown message queue when there's a send error
dirkmc Apr 16, 2020
9f70e8f
refactor: extract Connection Event Manager to own file and add tests
dirkmc Apr 16, 2020
026e4ba
test: add more testing for ipfs_impl
dirkmc Apr 16, 2020
679bc47
feat: dont retry if connect error is multistream.ErrNotSupported
dirkmc Apr 17, 2020
c5233e2
fix: copy opts in ipfs_impl
dirkmc Apr 17, 2020
18d41d1
fix: remove extraneous map writes in connectionEventManager
dirkmc Apr 17, 2020
05861de
fix: perf improvement for connectEventManager
dirkmc Apr 17, 2020
d3472ac
fix: simplify message queue shutdown
dirkmc Apr 17, 2020
5df9dc3
fix: avoid goroutine when receiving an error (#353)
Stebalien Apr 17, 2020
a6c6da7
fix: use explicit connected bool for streamMessageSender
dirkmc Apr 17, 2020
ac97f43
fix: ipfs_impl error handling
dirkmc Apr 17, 2020
123abbb
fix: mark wants sent when they are added to a message to be sent
dirkmc Apr 17, 2020
5d4b3f4
feat: optimize entry sorting in MessageQueue
dirkmc Apr 17, 2020
521c70c
Merge pull request ipfs/go-bitswap#351 from ipfs/refactor/conn-mgmt
Stebalien Apr 18, 2020
1d9cc58
Merge pull request ipfs/go-bitswap#356 from ipfs/feat/opt-mq-sort
Stebalien Apr 20, 2020
5d7fcc7
fix: minimize time holding wantlist lock (#361)
Stebalien Apr 21, 2020
7ce2dad
fix: ensure we shutdown the message queue asap (#362)
Stebalien Apr 21, 2020
f223da3
refactor: add reverse index to peerWantManager to speed up cancels (#…
dirkmc Apr 21, 2020
5cfe98e
feat: move broadcast wantlist into the peermanager (#365)
Stebalien Apr 22, 2020
573478d
fix: avoid calling ctx.SetDeadline() every time we send a message
dirkmc Apr 22, 2020
5e4dbaf
Merge pull request ipfs/go-bitswap#369 from ipfs/fix/over-allocated-ctx
Stebalien Apr 22, 2020
780e750
fix: change timing for DONT_HAVE timeouts to be more conservative
dirkmc Apr 22, 2020
8a31039
Merge pull request ipfs/go-bitswap#371 from ipfs/fix/dont-have-timing
Stebalien Apr 23, 2020
cef83ed
refactor: remove unused code
dirkmc Apr 23, 2020
b4ce47b
Merge pull request ipfs/go-bitswap#373 from ipfs/refactor/unref-old-code
Stebalien Apr 23, 2020
6ac6ced
refactor: remove WantManager
dirkmc Apr 23, 2020
497c51f
fix: race in session test
dirkmc Apr 23, 2020
d03b4a0
fix: send CANCELs when session context is cancelled
dirkmc Apr 23, 2020
8d0dcda
Merge pull request ipfs/go-bitswap#375 from ipfs/refactor/sess-ctx-ca…
Stebalien Apr 23, 2020
2a5234f
Merge pull request ipfs/go-bitswap#374 from ipfs/refactor/unref-want-mgr
Stebalien Apr 23, 2020
62d249d
Add standard issue template
hsanjuan Apr 27, 2020
6058fda
feat: calculate message latency
dirkmc Apr 29, 2020
4dac202
fix: simplify latency timing
dirkmc Apr 30, 2020
9971868
fix: only record latency for first response per want
dirkmc Apr 30, 2020
8a3442f
fix: discard outliers in latency calculation
dirkmc Apr 30, 2020
d56f8df
docs: MessageQueue docs
dirkmc May 1, 2020
6c9536b
fix: use one less go-routine per session (#377)
dirkmc May 1, 2020
522cdcc
test: fix flaky test TestSessionBetweenPeers
dirkmc May 1, 2020
486c683
Merge pull request ipfs/go-bitswap#386 from ipfs/feat/msg-latency
Stebalien May 2, 2020
d7517d4
fix: return wants from engine.WantlistForPeer()
dirkmc May 7, 2020
4eea052
Merge pull request ipfs/go-bitswap#390 from ipfs/fix/engine-wantlist
Stebalien May 7, 2020
64b50c8
perf: improve peer manager performance
dirkmc May 19, 2020
cbb4fee
perf: improve cancel wants perf
dirkmc May 20, 2020
ecb113b
feat: simplify broadcast cancel logic (#399)
Stebalien May 21, 2020
45841da
Merge pull request ipfs/go-bitswap#395 from ipfs/perf/peer-want-mgr
Stebalien May 21, 2020
55ed620
Total wants gauge (#402)
dirkmc Jun 2, 2020
8ebd663
fix: ensure sessions register with PeerManager
dirkmc Jun 3, 2020
6f58a27
Merge pull request ipfs/go-bitswap#405 from ipfs/fix/register-session
Stebalien Jun 3, 2020
1444b49
feat: protect connection for session peers that are first to send block
dirkmc Jun 3, 2020
ab06e35
fix: ensure conns are unprotected on shutdown
dirkmc Jun 3, 2020
6e9d928
fix: race in tests
dirkmc Jun 3, 2020
c107987
fix: ensure unique tag for session connection protection
dirkmc Jun 3, 2020
a6ee6dc
Merge pull request ipfs/go-bitswap#406 from ipfs/feat/protect-conns
Stebalien Jun 3, 2020
7d3c257
fix: only track useful received data in the ledger (#411)
Stebalien Jun 8, 2020
f64f9f0
fix: avoid taking accessing the peerQueues without taking the lock
Stebalien Jun 10, 2020
038064e
fix: want gauge calculation
dirkmc Jun 10, 2020
f01b977
fix: PeerManager signalAvailabiity() race
dirkmc Jun 10, 2020
c350dbd
refactor: simplify PeerWantManager pending want counts
dirkmc Jun 10, 2020
b33736d
fix: log error for unexpected reverse index mismatch
dirkmc Jun 10, 2020
553ddab
Merge pull request ipfs/go-bitswap#417 from ipfs/fix/peermgr-race
Stebalien Jun 10, 2020
29f8f54
Merge pull request ipfs/go-bitswap#416 from ipfs/fix/want-gauge
Stebalien Jun 10, 2020
38e601d
fix: don't say we're sending a full wantlist unless we are (#429)
Stebalien Aug 19, 2020
d8ded15
Added `WithScoreLedger` Bitswap option (#430)
wolneykien Sep 3, 2020
171ab60
refactor: remove extraneous ledger field init (#437)
dirkmc Sep 3, 2020
fb8d70f
Fix: Increment stats.MessagesSent in msgToStream() function (#441)
wolneykien Sep 10, 2020
643065d
Add WireTap interface (#444)
tzdybal Sep 24, 2020
47fcf13
fix: guard access to the mock wiretap with a lock
Stebalien Nov 10, 2020
86fde29
Merge pull request ipfs/go-bitswap#446 from ipfs/fix/wt-race
Stebalien Nov 10, 2020
70b8804
fix: update to go 1.15 lint warnings
Stebalien Sep 2, 2020
f15898f
feat: update for go-libp2p-core 0.7.0 interface changes
Stebalien Oct 27, 2020
84f3047
Merge pull request ipfs/go-bitswap#445 from ipfs/feat/rw-close
Stebalien Nov 12, 2020
0fc691a
fix: remove unnecessary (and leaked) ticker
Stebalien Nov 13, 2020
2c783dc
fix: set the score ledger on start
Stebalien Nov 13, 2020
f2e1722
Merge pull request ipfs/go-bitswap#447 from ipfs/fix/panic-and-leak
Stebalien Nov 13, 2020
22e7099
feat: configurable engine blockstore worker count (#449)
dirkmc Nov 18, 2020
21cce50
fix a startup race by creating the blockstoremanager process on init
Stebalien Feb 26, 2021
1bd02f9
Merge pull request ipfs/go-bitswap#465 from ipfs/fix/startup-race
Stebalien Feb 26, 2021
4773b3c
ignore transient connections
vyzo Apr 1, 2021
feacea7
Merge pull request ipfs/go-bitswap#470 from ipfs/fix/transient-conns
vyzo Apr 1, 2021
b25b462
fix staticcheck
Apr 15, 2021
a3fdc17
Merge pull request ipfs/go-bitswap#474 from coryschwartz/feat/fix-sta…
Stebalien Apr 21, 2021
67ee573
fix(network): impl: add timeout in newStreamToPeer call
schomatis Apr 22, 2021
82687b3
Merge pull request ipfs/go-bitswap#477 from ipfs/schomatis/impl/newSt…
Stebalien Apr 23, 2021
ae9d0af
fix: fix alignment of stats struct in virtual network
Stebalien Apr 30, 2021
69e518f
Merge pull request ipfs/go-bitswap#478 from ipfs/fix/alignment
Stebalien Apr 30, 2021
37c73da
test: deflake large-message test
Stebalien Apr 30, 2021
250f85f
test: deflake donthave timeout test
Stebalien Apr 30, 2021
8fb0b41
Merge pull request ipfs/go-bitswap#479 from ipfs/fix/deflake-large-me…
Stebalien Apr 30, 2021
3aef0c6
test: deflake engine test
Stebalien Apr 30, 2021
87653e1
Merge pull request ipfs/go-bitswap#480 from ipfs/fix/deflake-tag-test
Stebalien Apr 30, 2021
04c7fb6
remove Makefile
marten-seemann May 12, 2021
e650a28
Merge pull request ipfs/go-bitswap#483 from ipfs/remove-makefile
Stebalien May 12, 2021
696aa9e
run gofmt -s
web3-bot Jun 13, 2021
6c3c7ce
Merge pull request ipfs/go-bitswap#485 from ipfs/web3-bot/sync
Stebalien Jun 24, 2021
aed42ed
fix(decision): fix test flakiness through mock clock (#494)
hannahhoward Jun 4, 2021
e89ff30
fix(network): fix TestNetworkCounters
hannahhoward Jun 3, 2021
f2b9294
fix(bitswap): add send don't have timeout option
hannahhoward Jun 2, 2021
d0956dc
refactor(bitswap): rename simulateDontHaves option
hannahhoward Jun 3, 2021
d0625e3
fix(messagequeue): fix flaky TestDontHaveMgr tests
hannahhoward Jun 3, 2021
b0f7312
refactor(messagequeue): rename ambigous channel
hannahhoward Jun 5, 2021
deefc55
Merge pull request ipfs/go-bitswap#495 from ipfs/fix/fix-dont-have-ma…
Stebalien Jun 24, 2021
315215a
fix(messagequeue): fix flaky MessageQueue tests
hannahhoward Jun 5, 2021
867748a
fix: Nil dereference while using SetSendDontHaves
Jorropo May 30, 2021
9f393b5
docs: better engineSetSendDontHaves description
Jorropo Jun 16, 2021
a46d640
Merge pull request ipfs/go-bitswap#497 from ipfs/fix/message-queue-tests
Stebalien Jun 24, 2021
0f4401d
fix: hold the task worker lock when starting task workers
Stebalien Jun 24, 2021
d496037
Merge pull request ipfs/go-bitswap#488 from Jorropo/fix/nildereferanc…
Stebalien Jun 24, 2021
8c62bb5
Merge pull request ipfs/go-bitswap#504 from ipfs/fix/task-worker-coun…
Stebalien Jun 24, 2021
b186c21
remove unused haves parameter on Engine.ReceiveFrom
marten-seemann May 12, 2021
a37cc73
introduce a ledger that stores which peers are waiting for a Cid
marten-seemann May 12, 2021
602e77b
chore: go fmt
Stebalien Jun 24, 2021
0edb93f
fix: cleanup ledger on mismatch
Stebalien Jun 24, 2021
4862a80
Merge pull request ipfs/go-bitswap#486 from ipfs/optimize-receive-from
Stebalien Jun 24, 2021
4bebfb8
chore: update deps
Stebalien May 12, 2021
ec8d143
Merge pull request ipfs/go-bitswap#484 from ipfs/chore/update-libp2p
Stebalien Jun 24, 2021
ad9db9b
fix(decision): fix a datarace on disconnect
Stebalien Jun 24, 2021
1f14023
Merge pull request ipfs/go-bitswap#508 from ipfs/fix/disconnect-data-…
Stebalien Jun 24, 2021
f50ec7d
fix: make blockstore cancel test less timing dependent
Stebalien Jun 24, 2021
0ac12b2
Merge pull request ipfs/go-bitswap#507 from ipfs/test/blockstore-test…
Stebalien Jun 24, 2021
9d43811
fix: fix a map access race condition in the want index
Stebalien Jul 30, 2021
c6dc84c
Merge pull request ipfs/go-bitswap#523 from ipfs/fix/race
Stebalien Jul 30, 2021
911ab0b
More stats, knobs and tunings (#514)
petar Aug 18, 2021
ff5afd4
fix: reduce log verbosity
Stebalien Aug 31, 2021
5c0d350
fix: fix race on "responsive" check
Stebalien Sep 2, 2021
9701906
feat: cache the materialized wantlist
Stebalien Sep 7, 2021
04cf894
Merge pull request ipfs/go-bitswap#528 from ipfs/fix/responsive-check…
Stebalien Sep 15, 2021
11a8c51
fix: rename wiretap to tracer
Stebalien Sep 15, 2021
3a26de9
Merge pull request ipfs/go-bitswap#531 from ipfs/chore/rename-wiretap
Stebalien Sep 15, 2021
b73686f
test(providerquerymanager): fix timings
hannahhoward Oct 8, 2021
3672986
enable custom task prioritization logic
synzhu Oct 12, 2021
8757464
add peer to TaskInfo
synzhu Oct 12, 2021
b22ad0c
move task comparator wrapper to separate function
synzhu Oct 12, 2021
df1dd18
fix undeclared name error
synzhu Oct 13, 2021
868c9e0
Merge pull request ipfs/go-bitswap#534 from ipfs/fix/flaky-test-rate-…
Stebalien Oct 14, 2021
68d09d4
fix: reduce receive contention
Stebalien Oct 21, 2021
07bb124
Merge pull request ipfs/go-bitswap#536 from ipfs/fix/receive-contention
Stebalien Oct 26, 2021
f2bddb8
test: make sure the cache is cleared when changing the wantlist
Stebalien Oct 26, 2021
148294a
Merge pull request ipfs/go-bitswap#530 from ipfs/feat/cache-wantlist
Stebalien Oct 26, 2021
39f1c04
Add TaskComparator test
synzhu Oct 27, 2021
47fedf0
Add type aliases for TaskInfo and TaskComparator
synzhu Oct 27, 2021
5731bae
Merge pull request ipfs/go-bitswap#535 from smnzhu/master
Stebalien Oct 28, 2021
543d85c
fix: optimize handling for peers with lots of tasks
Stebalien Oct 26, 2021
1bb4f34
Merge pull request ipfs/go-bitswap#537 from ipfs/feat/optimize-has-ne…
Stebalien Oct 28, 2021
f8826c6
feat: plumb through contexts (#539)
guseggert Nov 10, 2021
bd52ae4
Change incorrect function name in README (#541)
susarlanikhilesh Nov 17, 2021
1cc4747
configurable target message size
whyrusleeping Dec 14, 2021
8a1063c
Merge pull request ipfs/go-bitswap#546 from ipfs/feat/allow-config-me…
Stebalien Dec 14, 2021
d8f0673
feat: add peer block filter option (#549)
laurentsenta Mar 17, 2022
b8a2174
Use ipld.ErrNotFound
hsanjuan Apr 7, 2020
424c9ec
fix initialisation example in README (#552)
marten-seemann Apr 22, 2022
396c4d8
feat: coalesce and queue connection event handling (#565)
Stebalien Jun 13, 2022
1d5a1fb
feat: add basic tracing (#562)
guseggert Jun 14, 2022
1327f92
Remove dependency on travis package from go-libp2p-testing
MarcoPolo Jul 1, 2022
f50bb2c
Merge pull request ipfs/go-bitswap#569 from ipfs/marco/rm-travis-dep
MarcoPolo Jul 5, 2022
0a12d4c
chore: Update .github/workflows/stale.yml [skip ci]
web-flow Jul 21, 2022
8e28164
feat: don't add blocks to the datastore
MichaelMure Jul 8, 2022
4f2f126
chore: bump deps & cleanup dont add
Jorropo Jul 28, 2022
4170132
Merge pull request ipfs/go-bitswap#571 from MichaelMure/no-block-add
Jorropo Jul 28, 2022
236ab37
chore: remove goprocess from blockstoremanager
guseggert Aug 5, 2022
8ebb187
refactor: split client and server and all sideeffects that this incurs
Jorropo Jun 20, 2022
ad3603b
refactor: remove the need of generics
Jorropo Aug 5, 2022
bb2458f
test: remove TestTracer
Jorropo Aug 6, 2022
0e7466c
refactor: remove metrics object and other review changes
Jorropo Aug 11, 2022
2c754a5
fix: plumb through ctor contexts to preserve metrics scopes
guseggert Aug 13, 2022
10c47cb
fix: message queue test races on Windows
guseggert Aug 13, 2022
ec22e05
Merge pull request ipfs/go-bitswap#570 from Jorropo/split
guseggert Aug 13, 2022
8364285
chore: update go-libp2p v0.22.0
Jorropo Aug 29, 2022
a64dcb1
chore: fix incorrect log message when a bad option is passed
Jorropo Sep 8, 2022
2e3f08c
fix: incorrect type in the WithTracer polyfill option
Jorropo Sep 8, 2022
c81c82e
fix: create a copy of the protocol slice in network.processSettings
Jorropo Sep 13, 2022
c3491de
bitswap: migrate ipfs/go-bitswap
Jorropo Jan 26, 2023
0a9cfb6
bitswap: mark all hybrid, client, server and network tests flaky
Jorropo Jan 27, 2023
3080787
chore: release v0.4.0
Jorropo Jan 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bitswap/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp
120 changes: 120 additions & 0 deletions bitswap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
go-bitswap
==================

> An implementation of the bitswap protocol in go!

## Table of Contents

- [Background](#background)
- [Usage](#usage)
- [Implementation](#implementation)
- [Contribute](#contribute)
- [License](#license)

## Background

Bitswap is the data trading module for ipfs. It manages requesting and sending
blocks to and from other peers in the network. Bitswap has two main jobs:
- to acquire blocks requested by the client from the network
- to judiciously send blocks in its possession to other peers who want them

Bitswap is a message based protocol, as opposed to request-response. All messages
contain wantlists or blocks.

A node sends a wantlist to tell peers which blocks it wants. When a node receives
a wantlist it should check which blocks it has from the wantlist, and consider
sending the matching blocks to the requestor.

When a node receives blocks that it asked for, the node should send out a
notification called a 'Cancel' to tell its peers that the node no longer
wants those blocks.

`go-bitswap` provides an implementation of the Bitswap protocol in go.

[Learn more about how Bitswap works](./docs/how-bitswap-works.md)

## Usage

### Initializing a Bitswap Exchange

```golang
import (
"context"
bitswap "github.com/ipfs/go-libipfs/bitswap"
bsnet "github.com/ipfs/go-libipfs/bitswap/network"
blockstore "github.com/ipfs/go-ipfs-blockstore"
"github.com/libp2p/go-libp2p-core/routing"
"github.com/libp2p/go-libp2p-core/host"
)

var ctx context.Context
var host host.Host
var router routing.ContentRouting
var bstore blockstore.Blockstore

network := bsnet.NewFromIpfsHost(host, router)
exchange := bitswap.New(ctx, network, bstore)
```

Parameter Notes:

1. `ctx` is just the parent context for all of Bitswap
2. `network` is a network abstraction provided to Bitswap on top of libp2p & content routing.
3. `bstore` is an IPFS blockstore

### Get A Block Synchronously

```golang
var c cid.Cid
var ctx context.Context
var exchange bitswap.Bitswap

block, err := exchange.GetBlock(ctx, c)
```

Parameter Notes:

1. `ctx` is the context for this request, which can be cancelled to cancel the request
2. `c` is the content ID of the block you're requesting

### Get Several Blocks Asynchronously

```golang
var cids []cid.Cid
var ctx context.Context
var exchange bitswap.Bitswap

blockChannel, err := exchange.GetBlocks(ctx, cids)
```

Parameter Notes:

1. `ctx` is the context for this request, which can be cancelled to cancel the request
2. `cids` is a slice of content IDs for the blocks you're requesting

### Get Related Blocks Faster With Sessions

In IPFS, content blocks are often connected to each other through a MerkleDAG. If you know ahead of time that block requests are related, Bitswap can make several optimizations internally in how it requests those blocks in order to get them faster. Bitswap provides a mechanism called a Bitswap Session to manage a series of block requests as part of a single higher level operation. You should initialize a Bitswap Session any time you intend to make a series of block requests that are related -- and whose responses are likely to come from the same peers.

```golang
var ctx context.Context
var cids []cids.cid
var exchange bitswap.Bitswap

session := exchange.NewSession(ctx)
blocksChannel, err := session.GetBlocks(ctx, cids)
// later
var relatedCids []cids.cid
relatedBlocksChannel, err := session.GetBlocks(ctx, relatedCids)
```

Note that `NewSession` returns an interface with `GetBlock` and `GetBlocks` methods that have the same signature as the overall Bitswap exchange.

### Tell bitswap a new block was added to the local datastore

```golang
var blk blocks.Block
var exchange bitswap.Bitswap

err := exchange.HasBlock(blk)
```
Loading