Skip to content

Commit

Permalink
make bitswap max message size configurable
Browse files Browse the repository at this point in the history
bump version to v0.7.3
  • Loading branch information
ianopolous committed Feb 26, 2024
1 parent dc12c7a commit a3c0e64
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.peergos</groupId>
<artifactId>nabu</artifactId>
<version>v0.7.2</version>
<version>v0.7.3</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/org/peergos/EmbeddedIpfs.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ public static Blockstore filteredBlockStore(Blockstore blocks, Config config) {
}
}

public static EmbeddedIpfs build(RecordStore records,
Blockstore blocks,
boolean provideBlocks,
List<MultiAddress> swarmAddresses,
List<MultiAddress> bootstrap,
IdentitySection identity,
BlockRequestAuthoriser authoriser,
Optional<HttpProtocol.HttpRequestProcessor> handler) {
return build(records, blocks, provideBlocks, swarmAddresses, bootstrap, identity, authoriser, handler,
Optional.empty(), Optional.empty());
}

public static EmbeddedIpfs build(RecordStore records,
Blockstore blocks,
boolean provideBlocks,
Expand All @@ -217,7 +229,8 @@ public static EmbeddedIpfs build(RecordStore records,
IdentitySection identity,
BlockRequestAuthoriser authoriser,
Optional<HttpProtocol.HttpRequestProcessor> handler,
Optional<String> bitswapProtocolId) {
Optional<String> bitswapProtocolId,
Optional<Integer> maxBitswapMsgSize) {
Blockstore blockstore = provideBlocks ?
new ProvidingBlockstore(blocks) :
blocks;
Expand All @@ -232,7 +245,8 @@ public static EmbeddedIpfs build(RecordStore records,
Kademlia dht = new Kademlia(new KademliaEngine(ourPeerId, providers, records, blockstore), false);
CircuitStopProtocol.Binding stop = new CircuitStopProtocol.Binding();
CircuitHopProtocol.RelayManager relayManager = CircuitHopProtocol.RelayManager.limitTo(builder.getPrivateKey(), ourPeerId, 5);
Bitswap bitswap = new Bitswap(bitswapProtocolId.orElse(Bitswap.PROTOCOL_ID), new BitswapEngine(blockstore, authoriser, Bitswap.MAX_MESSAGE_SIZE, true));
Bitswap bitswap = new Bitswap(bitswapProtocolId.orElse(Bitswap.PROTOCOL_ID),
new BitswapEngine(blockstore, authoriser, maxBitswapMsgSize.orElse(Bitswap.MAX_MESSAGE_SIZE), true));
Optional<HttpProtocol.Binding> httpHandler = handler.map(HttpProtocol.Binding::new);

List<ProtocolBinding> protocols = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public void buildAndSendMessages(List<MessageOuterClass.Message.Wantlist.Entry>
for (int i=0; i < blocks.size(); i++) {
MessageOuterClass.Message.Block block = blocks.get(i);
int blockSize = block.getSerializedSize();
if (blockSize + messageSize > Bitswap.MAX_MESSAGE_SIZE) {
if (blockSize + messageSize > maxMessageSize) {
sender.accept(builder.build());
builder = MessageOuterClass.Message.newBuilder();
messageSize = 0;
Expand Down

0 comments on commit a3c0e64

Please sign in to comment.