@helia/bitswap 3.1.3 → 3.1.4-11802dd6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/bitswap.d.ts +5 -5
- package/dist/src/bitswap.js +5 -5
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/network.d.ts +7 -7
- package/dist/src/network.d.ts.map +1 -1
- package/dist/src/network.js +4 -4
- package/dist/src/network.js.map +1 -1
- package/dist/src/pb/message.d.ts +133 -10
- package/dist/src/pb/message.d.ts.map +1 -1
- package/dist/src/pb/message.js +247 -27
- package/dist/src/pb/message.js.map +1 -1
- package/dist/src/peer-want-lists/index.d.ts +4 -4
- package/dist/src/peer-want-lists/index.js +1 -1
- package/dist/src/peer-want-lists/ledger.d.ts +3 -3
- package/dist/src/peer-want-lists/ledger.js +4 -4
- package/dist/src/session.d.ts +4 -3
- package/dist/src/session.d.ts.map +1 -1
- package/dist/src/session.js +6 -3
- package/dist/src/session.js.map +1 -1
- package/dist/src/utils/bitswap-message.d.ts +1 -1
- package/dist/src/utils/cid-prefix.js +1 -1
- package/dist/src/utils/merge-messages.d.ts +1 -1
- package/dist/src/utils/split-message.d.ts +1 -1
- package/dist/src/utils/split-message.js +2 -2
- package/dist/src/want-list.d.ts +3 -3
- package/dist/src/want-list.js +4 -4
- package/package.json +6 -6
- package/src/bitswap.ts +6 -6
- package/src/index.ts +3 -3
- package/src/network.ts +11 -10
- package/src/pb/message.ts +395 -17
- package/src/peer-want-lists/index.ts +4 -4
- package/src/peer-want-lists/ledger.ts +6 -6
- package/src/session.ts +10 -6
- package/src/utils/bitswap-message.ts +1 -1
- package/src/utils/cid-prefix.ts +1 -1
- package/src/utils/merge-messages.ts +1 -1
- package/src/utils/split-message.ts +3 -3
- package/src/want-list.ts +7 -7
- package/dist/typedoc-urls.json +0 -30
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import toBuffer from 'it-to-buffer'
|
|
2
2
|
import { CID } from 'multiformats/cid'
|
|
3
3
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
4
|
-
import { DEFAULT_MAX_SIZE_REPLACE_HAS_WITH_BLOCK, DEFAULT_DO_NOT_RESEND_BLOCK_WINDOW, DEFAULT_MAX_WANTLIST_SIZE } from '../constants.
|
|
5
|
-
import { BlockPresenceType, WantType } from '../pb/message.
|
|
6
|
-
import { QueuedBitswapMessage } from '../utils/bitswap-message.
|
|
7
|
-
import { cidToPrefix } from '../utils/cid-prefix.
|
|
8
|
-
import type { Network } from '../network.
|
|
9
|
-
import type { Wantlist } from '../pb/message.
|
|
4
|
+
import { DEFAULT_MAX_SIZE_REPLACE_HAS_WITH_BLOCK, DEFAULT_DO_NOT_RESEND_BLOCK_WINDOW, DEFAULT_MAX_WANTLIST_SIZE } from '../constants.ts'
|
|
5
|
+
import { BlockPresenceType, WantType } from '../pb/message.ts'
|
|
6
|
+
import { QueuedBitswapMessage } from '../utils/bitswap-message.ts'
|
|
7
|
+
import { cidToPrefix } from '../utils/cid-prefix.ts'
|
|
8
|
+
import type { Network } from '../network.ts'
|
|
9
|
+
import type { Wantlist } from '../pb/message.ts'
|
|
10
10
|
import type { AbortOptions, ComponentLogger, Logger, PeerId } from '@libp2p/interface'
|
|
11
11
|
import type { Blockstore } from 'interface-blockstore'
|
|
12
12
|
|
package/src/session.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AbstractSession } from '@helia/utils'
|
|
2
2
|
import { isPeerId } from '@libp2p/interface'
|
|
3
3
|
import { CustomProgressEvent } from 'progress-events'
|
|
4
|
-
import type { BitswapProvider, BitswapWantProgressEvents } from './index.
|
|
5
|
-
import type { Network } from './network.
|
|
6
|
-
import type { WantList } from './want-list.
|
|
4
|
+
import type { BitswapProvider, BitswapWantProgressEvents } from './index.ts'
|
|
5
|
+
import type { Network } from './network.ts'
|
|
6
|
+
import type { WantList } from './want-list.ts'
|
|
7
7
|
import type { BlockRetrievalOptions, CreateSessionOptions } from '@helia/interface'
|
|
8
8
|
import type { ComponentLogger, Libp2p, PeerId } from '@libp2p/interface'
|
|
9
9
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
@@ -20,6 +20,7 @@ export interface BitswapSessionComponents {
|
|
|
20
20
|
interface ProviderPeer {
|
|
21
21
|
peerId: PeerId
|
|
22
22
|
routing: string
|
|
23
|
+
toString(): string
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
class BitswapSession extends AbstractSession<ProviderPeer, BitswapWantProgressEvents> {
|
|
@@ -57,7 +58,8 @@ class BitswapSession extends AbstractSession<ProviderPeer, BitswapWantProgressEv
|
|
|
57
58
|
for await (const provider of this.network.findProviders(cid, options)) {
|
|
58
59
|
yield {
|
|
59
60
|
peerId: provider.id,
|
|
60
|
-
routing: provider.routing
|
|
61
|
+
routing: provider.routing,
|
|
62
|
+
toString: () => `Bitswap(${provider.id})`
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
}
|
|
@@ -74,7 +76,8 @@ class BitswapSession extends AbstractSession<ProviderPeer, BitswapWantProgressEv
|
|
|
74
76
|
if (isPeerId(provider)) {
|
|
75
77
|
return {
|
|
76
78
|
peerId: provider,
|
|
77
|
-
routing
|
|
79
|
+
routing,
|
|
80
|
+
toString: () => `Bitswap(${provider})`
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
|
|
@@ -87,7 +90,8 @@ class BitswapSession extends AbstractSession<ProviderPeer, BitswapWantProgressEv
|
|
|
87
90
|
|
|
88
91
|
return {
|
|
89
92
|
peerId: connection.remotePeer,
|
|
90
|
-
routing
|
|
93
|
+
routing,
|
|
94
|
+
toString: () => `Bitswap(${connection.remotePeer})`
|
|
91
95
|
}
|
|
92
96
|
} catch {}
|
|
93
97
|
}
|
package/src/utils/cid-prefix.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueuedBitswapMessage } from './bitswap-message.
|
|
1
|
+
import type { QueuedBitswapMessage } from './bitswap-message.ts'
|
|
2
2
|
|
|
3
3
|
export function mergeMessages (existingMessage: QueuedBitswapMessage, newMessage: QueuedBitswapMessage): QueuedBitswapMessage {
|
|
4
4
|
for (const [key, entry] of newMessage.wantlist.entries()) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { encodingLength } from 'uint8-varint'
|
|
2
|
-
import { BlockTooLargeError } from '../errors.
|
|
3
|
-
import { BitswapMessage, Block, BlockPresence, WantlistEntry } from '../pb/message.
|
|
4
|
-
import type { QueuedBitswapMessage } from './bitswap-message.
|
|
2
|
+
import { BlockTooLargeError } from '../errors.ts'
|
|
3
|
+
import { BitswapMessage, Block, BlockPresence, WantlistEntry } from '../pb/message.ts'
|
|
4
|
+
import type { QueuedBitswapMessage } from './bitswap-message.ts'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* https://github.com/ipfs/kubo/issues/4473#issuecomment-350390693
|
package/src/want-list.ts
CHANGED
|
@@ -7,13 +7,13 @@ import pDefer from 'p-defer'
|
|
|
7
7
|
import { raceEvent } from 'race-event'
|
|
8
8
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
9
9
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
10
|
-
import { DEFAULT_MESSAGE_SEND_DELAY } from './constants.
|
|
11
|
-
import { BlockPresenceType, WantType } from './pb/message.
|
|
12
|
-
import { QueuedBitswapMessage } from './utils/bitswap-message.
|
|
13
|
-
import vd from './utils/varint-decoder.
|
|
14
|
-
import type { BitswapNotifyProgressEvents, MultihashHasherLoader } from './index.
|
|
15
|
-
import type { BitswapNetworkWantProgressEvents, Network } from './network.
|
|
16
|
-
import type { BitswapMessage } from './pb/message.
|
|
10
|
+
import { DEFAULT_MESSAGE_SEND_DELAY } from './constants.ts'
|
|
11
|
+
import { BlockPresenceType, WantType } from './pb/message.ts'
|
|
12
|
+
import { QueuedBitswapMessage } from './utils/bitswap-message.ts'
|
|
13
|
+
import vd from './utils/varint-decoder.ts'
|
|
14
|
+
import type { BitswapNotifyProgressEvents, MultihashHasherLoader } from './index.ts'
|
|
15
|
+
import type { BitswapNetworkWantProgressEvents, Network } from './network.ts'
|
|
16
|
+
import type { BitswapMessage } from './pb/message.ts'
|
|
17
17
|
import type { ComponentLogger, PeerId, Startable, AbortOptions, Libp2p, TypedEventTarget, Metrics } from '@libp2p/interface'
|
|
18
18
|
import type { Logger } from '@libp2p/logger'
|
|
19
19
|
import type { PeerMap } from '@libp2p/peer-collections'
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"codec": "https://ipfs.github.io/helia/functions/_helia_bitswap.WantType.codec.html",
|
|
3
|
-
"WantType": "https://ipfs.github.io/helia/enums/_helia_bitswap.WantType.html",
|
|
4
|
-
"Bitswap": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.Bitswap.html",
|
|
5
|
-
".:Bitswap": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.Bitswap.html",
|
|
6
|
-
"BitswapComponents": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapComponents.html",
|
|
7
|
-
".:BitswapComponents": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapComponents.html",
|
|
8
|
-
"BitswapOptions": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapOptions.html",
|
|
9
|
-
".:BitswapOptions": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapOptions.html",
|
|
10
|
-
"BitswapProvider": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapProvider.html",
|
|
11
|
-
"MultihashHasherLoader": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.MultihashHasherLoader.html",
|
|
12
|
-
".:MultihashHasherLoader": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.MultihashHasherLoader.html",
|
|
13
|
-
"PeerWantListEntry": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.PeerWantListEntry.html",
|
|
14
|
-
".:PeerWantListEntry": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.PeerWantListEntry.html",
|
|
15
|
-
"WantListEntry": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.WantListEntry.html",
|
|
16
|
-
".:WantListEntry": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.WantListEntry.html",
|
|
17
|
-
"BitswapNetworkNotifyProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapNetworkNotifyProgressEvents.html",
|
|
18
|
-
"BitswapNetworkProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapNetworkProgressEvents.html",
|
|
19
|
-
"BitswapNetworkWantProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapNetworkWantProgressEvents.html",
|
|
20
|
-
"BitswapNotifyProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapNotifyProgressEvents.html",
|
|
21
|
-
".:BitswapNotifyProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapNotifyProgressEvents.html",
|
|
22
|
-
"BitswapWantBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapWantBlockProgressEvents.html",
|
|
23
|
-
".:BitswapWantBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapWantBlockProgressEvents.html",
|
|
24
|
-
"BitswapWantProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapWantProgressEvents.html",
|
|
25
|
-
".:BitswapWantProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapWantProgressEvents.html",
|
|
26
|
-
"WantStatus": "https://ipfs.github.io/helia/types/_helia_bitswap.WantStatus.html",
|
|
27
|
-
".:WantStatus": "https://ipfs.github.io/helia/types/_helia_bitswap.WantStatus.html",
|
|
28
|
-
"createBitswap": "https://ipfs.github.io/helia/functions/_helia_bitswap.createBitswap.html",
|
|
29
|
-
".:createBitswap": "https://ipfs.github.io/helia/functions/_helia_bitswap.createBitswap.html"
|
|
30
|
-
}
|