Set uid inside constructor

This commit is contained in:
chimp1984 2021-01-11 14:17:34 -05:00
parent 873b557ce8
commit 7a2501ea1b
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3
4 changed files with 11 additions and 13 deletions

View file

@ -68,7 +68,6 @@ import javafx.beans.property.SimpleIntegerProperty;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -427,8 +426,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
// send it if peer has not updated. // send it if peer has not updated.
PrefixedSealedAndSignedMessage sealedMsg = new PrefixedSealedAndSignedMessage( PrefixedSealedAndSignedMessage sealedMsg = new PrefixedSealedAndSignedMessage(
networkNode.getNodeAddress(), networkNode.getNodeAddress(),
encryptionService.encryptAndSign(pubKeyRing, message), encryptionService.encryptAndSign(pubKeyRing, message));
UUID.randomUUID().toString());
SettableFuture<Connection> future = networkNode.sendMessage(peersNodeAddress, sealedMsg); SettableFuture<Connection> future = networkNode.sendMessage(peersNodeAddress, sealedMsg);
Futures.addCallback(future, new FutureCallback<>() { Futures.addCallback(future, new FutureCallback<>() {

View file

@ -25,6 +25,8 @@ import bisq.common.proto.network.NetworkEnvelope;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import java.util.UUID;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Value; import lombok.Value;
@ -43,9 +45,12 @@ public final class PrefixedSealedAndSignedMessage extends NetworkEnvelope implem
private final String uid; private final String uid;
public PrefixedSealedAndSignedMessage(NodeAddress senderNodeAddress, public PrefixedSealedAndSignedMessage(NodeAddress senderNodeAddress,
SealedAndSigned sealedAndSigned, SealedAndSigned sealedAndSigned) {
String uid) { this(senderNodeAddress,
this(senderNodeAddress, sealedAndSigned, new byte[0], uid, Version.getP2PMessageVersion()); sealedAndSigned,
new byte[0],
UUID.randomUUID().toString(),
Version.getP2PMessageVersion());
} }

View file

@ -73,7 +73,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -203,8 +202,7 @@ public class MailboxMessageService implements SetupListener, RequestDataManager.
try { try {
PrefixedSealedAndSignedMessage prefixedSealedAndSignedMessage = new PrefixedSealedAndSignedMessage( PrefixedSealedAndSignedMessage prefixedSealedAndSignedMessage = new PrefixedSealedAndSignedMessage(
networkNode.getNodeAddress(), networkNode.getNodeAddress(),
encryptionService.encryptAndSign(peersPubKeyRing, message), encryptionService.encryptAndSign(peersPubKeyRing, message));
UUID.randomUUID().toString());
SettableFuture<Connection> future = networkNode.sendMessage(peer, prefixedSealedAndSignedMessage); SettableFuture<Connection> future = networkNode.sendMessage(peer, prefixedSealedAndSignedMessage);
Futures.addCallback(future, new FutureCallback<>() { Futures.addCallback(future, new FutureCallback<>() {
@Override @Override

View file

@ -41,8 +41,6 @@ import java.time.Clock;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Before; import org.junit.Before;
@ -69,8 +67,7 @@ public class AddDataMessageTest {
@Test @Test
public void toProtoBuf() throws Exception { public void toProtoBuf() throws Exception {
SealedAndSigned sealedAndSigned = new SealedAndSigned(RandomUtils.nextBytes(10), RandomUtils.nextBytes(10), RandomUtils.nextBytes(10), keyRing1.getPubKeyRing().getSignaturePubKey()); SealedAndSigned sealedAndSigned = new SealedAndSigned(RandomUtils.nextBytes(10), RandomUtils.nextBytes(10), RandomUtils.nextBytes(10), keyRing1.getPubKeyRing().getSignaturePubKey());
PrefixedSealedAndSignedMessage prefixedSealedAndSignedMessage = new PrefixedSealedAndSignedMessage(new NodeAddress("host", 1000), sealedAndSigned, PrefixedSealedAndSignedMessage prefixedSealedAndSignedMessage = new PrefixedSealedAndSignedMessage(new NodeAddress("host", 1000), sealedAndSigned);
UUID.randomUUID().toString());
MailboxStoragePayload mailboxStoragePayload = new MailboxStoragePayload(prefixedSealedAndSignedMessage, MailboxStoragePayload mailboxStoragePayload = new MailboxStoragePayload(prefixedSealedAndSignedMessage,
keyRing1.getPubKeyRing().getSignaturePubKey(), keyRing1.getPubKeyRing().getSignaturePubKey()); keyRing1.getPubKeyRing().getSignaturePubKey(), keyRing1.getPubKeyRing().getSignaturePubKey());
ProtectedStorageEntry protectedStorageEntry = new ProtectedMailboxStorageEntry(mailboxStoragePayload, ProtectedStorageEntry protectedStorageEntry = new ProtectedMailboxStorageEntry(mailboxStoragePayload,