Skip to content

Commit

Permalink
Rename auth parameter in Want to authHex
Browse files Browse the repository at this point in the history
  • Loading branch information
ianopolous committed Jul 12, 2023
1 parent 2c200af commit df08779
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/peergos/Want.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

public class Want {
public final Cid cid;
public final Optional<String> auth;
public Want(Cid cid, Optional<String> auth) {
public final Optional<String> authHex;
public Want(Cid cid, Optional<String> authHex) {
this.cid = cid;
this.auth = auth.flatMap(a -> a.isEmpty() ? Optional.empty() : Optional.of(a));
this.authHex = authHex.flatMap(a -> a.isEmpty() ? Optional.empty() : Optional.of(a));
}

public Want(Cid h) {
Expand All @@ -21,11 +21,11 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Want want = (Want) o;
return cid.equals(want.cid) && auth.equals(want.auth);
return cid.equals(want.cid) && authHex.equals(want.authHex);
}

@Override
public int hashCode() {
return Objects.hash(cid, auth);
return Objects.hash(cid, authHex);
}
}
3 changes: 1 addition & 2 deletions src/main/java/org/peergos/protocol/bitswap/Bitswap.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.peergos.protocol.bitswap;

import com.google.protobuf.*;
import io.ipfs.cid.*;
import io.ipfs.multihash.Multihash;
import io.libp2p.core.*;
import io.libp2p.core.multiformats.*;
Expand Down Expand Up @@ -75,7 +74,7 @@ public void sendWants(Host us, Set<PeerId> peers) {
MessageOuterClass.Message.Wantlist.WantType.Block :
MessageOuterClass.Message.Wantlist.WantType.Have)
.setBlock(ByteString.copyFrom(want.cid.toBytes()))
.setAuth(ByteString.copyFrom(ArrayOps.hexToBytes(want.auth.orElse(""))))
.setAuth(ByteString.copyFrom(ArrayOps.hexToBytes(want.authHex.orElse(""))))
.build())
.collect(Collectors.toList());
engine.buildAndSendMessages(wantsProto, Collections.emptyList(), Collections.emptyList(),
Expand Down

0 comments on commit df08779

Please sign in to comment.