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

(6/6) Clean up technical debt in P2PDataStorage and ProtectedStorageEntry objects #3747

Merged
merged 51 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5fcd18c
[TESTS] Add tests of requestData
julianknutsen Nov 20, 2019
1e814d9
[REFACTOR] Introduce buildGetDataRequest variants
julianknutsen Nov 20, 2019
a927ed4
[TESTS] Add tests of new RequestData APIs
julianknutsen Nov 20, 2019
daffe6d
[TESTS] Add tests of GetDataRequestHandler
julianknutsen Nov 21, 2019
944b3ff
[REFACTOR] Introduce buildGetDataResponse
julianknutsen Nov 21, 2019
8208f78
[REFACTOR] Extract connectionInfo String
julianknutsen Nov 21, 2019
5402155
[REFACTOR] Extract getDataResponse logging
julianknutsen Nov 21, 2019
a6e8868
[REFACTOR] Extract truncation logging
julianknutsen Nov 21, 2019
dafc762
[REFACTOR] Pass peerCapabilities into buildGetDataResponse
julianknutsen Nov 21, 2019
5630b35
[TESTS] Unit tests of buildGetDataResponse
julianknutsen Nov 21, 2019
caf946d
Remove redundant HashSet lookups in filter functions
julianknutsen Nov 21, 2019
703a9a0
[REFACTOR] Move required capabilities log
julianknutsen Nov 21, 2019
3aaf8a2
[REFACTOR] Inline capability check for ProtectedStorageEntries
julianknutsen Nov 21, 2019
4c5d818
[REFACTOR] Inline filtering functions
julianknutsen Nov 21, 2019
e767340
[REFACTOR] Remove duplication in filtering functions
julianknutsen Nov 21, 2019
00128d9
[BUGFIX] Fix off-by-one in truncation logic
julianknutsen Nov 21, 2019
c7bce9e
[TESTS] Add test of RequestDataHandler::onMessage
julianknutsen Nov 21, 2019
873271c
[REFACTOR] Introduce processGetDataResponse
julianknutsen Nov 21, 2019
690b980
[TESTS] Make verify() functions more flexible
julianknutsen Nov 21, 2019
a34488b
[TESTS] Add unit tests for processGetDataResponse
julianknutsen Nov 21, 2019
3d6e9fb
Remove static from initialRequestApplied
julianknutsen Nov 21, 2019
f92893b
[TESTS] Write synchronization integration tests
julianknutsen Nov 21, 2019
5db1285
[REFACTOR] Clean up processGetDataResponse
julianknutsen Nov 22, 2019
ecae31e
[RENAME] LazyProcessedPayload to ProcessOncePersistableNetworkPayload
julianknutsen Nov 22, 2019
a0fae12
Remove @Nullable around persistableNetworkPayloadSet
julianknutsen Nov 22, 2019
c503bcb
Remove @Nullable around supportedCapabilities in GetDataResponse
julianknutsen Nov 22, 2019
b1a06fe
Remove @Nullable around supportedCapabilities in PreliminaryGetDataRe…
julianknutsen Nov 22, 2019
4fe19ae
[DEADCODE] Remove old request handler tests
julianknutsen Nov 22, 2019
0649323
Make addPersistableNetworkPayloadFromInitialRequest private
julianknutsen Nov 23, 2019
56a7661
[REFACTOR] Clean up ClientAPI for addPersistableNetworkPayload
julianknutsen Nov 22, 2019
0e6b1a2
[REFACTOR] Clean up ClientAPI for addProtectedStorageEntry
julianknutsen Nov 22, 2019
77413c9
[REFACTOR] Clean up ClientAPI for remove
julianknutsen Nov 22, 2019
9f69134
[REFACTOR] Clean up ClientAPI for refreshTTL
julianknutsen Nov 22, 2019
bfdb8f5
Make isDataOwner a private policy decision in BroadcastHandler
julianknutsen Nov 23, 2019
4dc4532
Remove isDataOwner from P2PDataStorage
julianknutsen Nov 23, 2019
6ff8756
[REFACTOR] inline broadcast() private function
julianknutsen Nov 22, 2019
5a174d5
[REFACTOR] inline broadcastProtectedStorageEntry() private function
julianknutsen Nov 22, 2019
1bd450b
[REFACTOR] inline maybeAddToRemoveAddOncePayloads() private function
julianknutsen Nov 22, 2019
17f4b70
[TESTS] Clean up mockito never() and eq(null) usages
julianknutsen Nov 23, 2019
b6b0026
Remove ProtectedStorageEntry::updateSignature
julianknutsen Nov 23, 2019
24ecfc7
Remove ProtectedStorageEntry::maybeAdjustCreationTimeStamp
julianknutsen Nov 23, 2019
0c67608
@NotNull ProtectedStorageEntry::ownerPubKey
julianknutsen Nov 23, 2019
76e8c57
@NotNull ProtectedStorageEntry::protectedStoragePayload
julianknutsen Nov 23, 2019
104984c
@NotNull MailboxStoragePayload::senderPubKeyForAddOperation
julianknutsen Nov 23, 2019
01a7f79
Make CHECK_TTL_INTERVAL_SEC final
julianknutsen Dec 4, 2019
c38ff9b
s/networkPayload/protectedStoragePayload
julianknutsen Dec 5, 2019
688405b
[TESTS] Make onDisconnect tests more robust
julianknutsen Dec 5, 2019
df2e4cc
Refactor P2PDataStorage::onDisconnect
julianknutsen Dec 5, 2019
b166009
Remove expire optimization in onDisconnect
julianknutsen Dec 5, 2019
7b8d346
Remove filter for ExpirablePayload
julianknutsen Dec 5, 2019
e8c8225
[PR COMMENTS] Fix comment typo
julianknutsen Dec 9, 2019
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
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/account/sign/SignedWitness.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.CapabilityRequiringPayload;
import bisq.network.p2p.storage.payload.DateTolerantPayload;
import bisq.network.p2p.storage.payload.LazyProcessedPayload;
import bisq.network.p2p.storage.payload.ProcessOncePersistableNetworkPayload;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;

import bisq.common.app.Capabilities;
Expand All @@ -45,7 +45,7 @@
// Supports signatures made from EC key (arbitrators) and signature created with DSA key.
@Slf4j
@Value
public class SignedWitness implements LazyProcessedPayload, PersistableNetworkPayload, PersistableEnvelope,
public class SignedWitness implements ProcessOncePersistableNetworkPayload, PersistableNetworkPayload, PersistableEnvelope,
DateTolerantPayload, CapabilityRequiringPayload {

public enum VerificationMethod {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.DateTolerantPayload;
import bisq.network.p2p.storage.payload.LazyProcessedPayload;
import bisq.network.p2p.storage.payload.ProcessOncePersistableNetworkPayload;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;

import bisq.common.proto.persistable.PersistableEnvelope;
Expand All @@ -40,7 +40,7 @@
// so only the newly added objects since the last release will be retrieved over the P2P network.
@Slf4j
@Value
public class AccountAgeWitness implements LazyProcessedPayload, PersistableNetworkPayload, PersistableEnvelope, DateTolerantPayload {
public class AccountAgeWitness implements ProcessOncePersistableNetworkPayload, PersistableNetworkPayload, PersistableEnvelope, DateTolerantPayload {
private static final long TOLERANCE = TimeUnit.DAYS.toMillis(1);

private final byte[] hash; // Ripemd160(Sha256(concatenated accountHash, signature and sigPubKey)); 20 bytes
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/alert/AlertManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public boolean addAlertMessageIfKeyIsValid(Alert alert, String privKeyString) {
if (isKeyValid) {
signAndAddSignatureToAlertMessage(alert);
user.setDevelopersAlert(alert);
boolean result = p2PService.addProtectedStorageEntry(alert, true);
boolean result = p2PService.addProtectedStorageEntry(alert);
if (result) {
log.trace("Add alertMessage to network was successful. AlertMessage={}", alert);
}
Expand All @@ -139,7 +139,7 @@ public boolean addAlertMessageIfKeyIsValid(Alert alert, String privKeyString) {
public boolean removeAlertMessageIfKeyIsValid(String privKeyString) {
Alert alert = user.getDevelopersAlert();
if (isKeyValid(privKeyString) && alert != null) {
if (p2PService.removeData(alert, true))
if (p2PService.removeData(alert))
log.trace("Remove alertMessage from network was successful. AlertMessage={}", alert);

user.setDevelopersAlert(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void onFailure(TxBroadcastException exception) {

public boolean remove(Proposal proposal) {
if (canRemoveProposal(proposal, daoStateService, periodService)) {
boolean success = p2PService.removeData(new TempProposalPayload(proposal, signaturePubKey), true);
boolean success = p2PService.removeData(new TempProposalPayload(proposal, signaturePubKey));
if (!success)
log.warn("Removal of proposal from p2p network failed. proposal={}", proposal);

Expand Down Expand Up @@ -214,7 +214,7 @@ private void addToP2PNetworkAsProtectedData(Proposal proposal, ErrorMessageHandl
}

private boolean addToP2PNetworkAsProtectedData(Proposal proposal) {
return p2PService.addProtectedStorageEntry(new TempProposalPayload(proposal, signaturePubKey), true);
return p2PService.addProtectedStorageEntry(new TempProposalPayload(proposal, signaturePubKey));
}

private void rePublishMyProposalsOnceWellConnected() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import bisq.core.dao.state.model.governance.Proposal;

import bisq.network.p2p.storage.payload.ExpirablePayload;
import bisq.network.p2p.storage.payload.LazyProcessedPayload;
import bisq.network.p2p.storage.payload.ProcessOncePersistableNetworkPayload;
import bisq.network.p2p.storage.payload.ProtectedStoragePayload;

import bisq.common.crypto.Sig;
Expand Down Expand Up @@ -55,7 +55,7 @@
@Getter
@EqualsAndHashCode
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
public class TempProposalPayload implements LazyProcessedPayload, ProtectedStoragePayload,
public class TempProposalPayload implements ProcessOncePersistableNetworkPayload, ProtectedStoragePayload,
ExpirablePayload, PersistablePayload {

protected final Proposal proposal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void requestHashesFromAllConnectedSeedNodes(int fromHeight) {

public void broadcastMyStateHash(StH myStateHash) {
NewStateHashMessage newStateHashMessage = getNewStateHashMessage(myStateHash);
broadcaster.broadcast(newStateHashMessage, networkNode.getNodeAddress(), null, true);
broadcaster.broadcast(newStateHashMessage, networkNode.getNodeAddress(), null);
}

public void requestHashes(int fromHeight, String peersAddress) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void publishNewBlock(Block block) {
log.info("Publish new block at height={} and block hash={}", block.getHeight(), block.getHash());
RawBlock rawBlock = RawBlock.fromBlock(block);
NewBlockBroadcastMessage newBlockBroadcastMessage = new NewBlockBroadcastMessage(rawBlock);
broadcaster.broadcast(newBlockBroadcastMessage, networkNode.getNodeAddress(), null, true);
broadcaster.broadcast(newBlockBroadcastMessage, networkNode.getNodeAddress(), null);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public void onMessage(NetworkEnvelope networkEnvelope, Connection connection) {
log.debug("We received a new message from peer {} and broadcast it to our peers. extBlockId={}",
connection.getPeersNodeAddressOptional().orElse(null), extBlockId);
receivedBlocks.add(extBlockId);
broadcaster.broadcast(newBlockBroadcastMessage, networkNode.getNodeAddress(), null, false);
broadcaster.broadcast(newBlockBroadcastMessage, connection.getPeersNodeAddressOptional().orElse(null), null);
listeners.forEach(listener -> listener.onNewBlockReceived(newBlockBroadcastMessage));
} else {
log.debug("We had that message already and do not further broadcast it. extBlockId={}", extBlockId);
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/filter/FilterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public boolean addFilterMessageIfKeyIsValid(Filter filter, String privKeyString)
signAndAddSignatureToFilter(filter);
user.setDevelopersFilter(filter);

boolean result = p2PService.addProtectedStorageEntry(filter, true);
boolean result = p2PService.addProtectedStorageEntry(filter);
if (result)
log.trace("Add filter to network was successful. FilterMessage = {}", filter);

Expand All @@ -278,7 +278,7 @@ public boolean removeFilterMessageIfKeyIsValid(String privKeyString) {
Filter filter = user.getDevelopersFilter();
if (filter == null) {
log.warn("Developers filter is null");
} else if (p2PService.removeData(filter, true)) {
} else if (p2PService.removeData(filter)) {
log.trace("Remove filter from network was successful. FilterMessage = {}", filter);
user.setDevelopersFilter(null);
} else {
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/bisq/core/offer/OfferBookService.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void addOffer(Offer offer, ResultHandler resultHandler, ErrorMessageHandl
return;
}

boolean result = p2PService.addProtectedStorageEntry(offer.getOfferPayload(), true);
boolean result = p2PService.addProtectedStorageEntry(offer.getOfferPayload());
if (result) {
resultHandler.handleResult();
} else {
Expand All @@ -164,7 +164,7 @@ public void refreshTTL(OfferPayload offerPayload,
return;
}

boolean result = p2PService.refreshTTL(offerPayload, true);
boolean result = p2PService.refreshTTL(offerPayload);
if (result) {
resultHandler.handleResult();
} else {
Expand All @@ -187,7 +187,7 @@ public void deactivateOffer(OfferPayload offerPayload,
public void removeOffer(OfferPayload offerPayload,
@Nullable ResultHandler resultHandler,
@Nullable ErrorMessageHandler errorMessageHandler) {
if (p2PService.removeData(offerPayload, true)) {
if (p2PService.removeData(offerPayload)) {
if (resultHandler != null)
resultHandler.handleResult();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void addDisputeAgent(T disputeAgent,
log.debug("addDisputeAgent disputeAgent.hashCode() " + disputeAgent.hashCode());
if (!BisqEnvironment.getBaseCurrencyNetwork().isMainnet() ||
!Utilities.encodeToHex(disputeAgent.getRegistrationPubKey()).equals(DevEnv.DEV_PRIVILEGE_PUB_KEY)) {
boolean result = p2PService.addProtectedStorageEntry(disputeAgent, true);
boolean result = p2PService.addProtectedStorageEntry(disputeAgent);
if (result) {
log.trace("Add disputeAgent to network was successful. DisputeAgent.hashCode() = " + disputeAgent.hashCode());
resultHandler.handleResult();
Expand All @@ -81,7 +81,7 @@ public void removeDisputeAgent(T disputeAgent,
ResultHandler resultHandler,
ErrorMessageHandler errorMessageHandler) {
log.debug("removeDisputeAgent disputeAgent.hashCode() " + disputeAgent.hashCode());
if (p2PService.removeData(disputeAgent, true)) {
if (p2PService.removeData(disputeAgent)) {
log.trace("Remove disputeAgent from network was successful. DisputeAgent.hashCode() = " + disputeAgent.hashCode());
resultHandler.handleResult();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import bisq.core.offer.OfferPayload;

import bisq.network.p2p.storage.payload.ExpirablePayload;
import bisq.network.p2p.storage.payload.LazyProcessedPayload;
import bisq.network.p2p.storage.payload.ProcessOncePersistableNetworkPayload;
import bisq.network.p2p.storage.payload.ProtectedStoragePayload;

import bisq.common.crypto.Sig;
Expand Down Expand Up @@ -60,7 +60,7 @@
@Slf4j
@EqualsAndHashCode(exclude = {"signaturePubKeyBytes"})
@Value
public final class TradeStatistics implements LazyProcessedPayload, ProtectedStoragePayload, ExpirablePayload, PersistablePayload {
public final class TradeStatistics implements ProcessOncePersistableNetworkPayload, ProtectedStoragePayload, ExpirablePayload, PersistablePayload {
private final OfferPayload.Direction direction;
private final String baseCurrency;
private final String counterCurrency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import bisq.core.offer.OfferUtil;

import bisq.network.p2p.storage.payload.CapabilityRequiringPayload;
import bisq.network.p2p.storage.payload.LazyProcessedPayload;
import bisq.network.p2p.storage.payload.ProcessOncePersistableNetworkPayload;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;

import bisq.common.app.Capabilities;
Expand Down Expand Up @@ -63,7 +63,7 @@

@Slf4j
@Value
public final class TradeStatistics2 implements LazyProcessedPayload, PersistableNetworkPayload, PersistableEnvelope, CapabilityRequiringPayload {
public final class TradeStatistics2 implements ProcessOncePersistableNetworkPayload, PersistableNetworkPayload, PersistableEnvelope, CapabilityRequiringPayload {

//We don't support arbitrators anymore so this entry will be only for pre v1.2. trades
@Deprecated
Expand Down
19 changes: 7 additions & 12 deletions monitor/src/main/java/bisq/monitor/metric/P2PMarketStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,15 @@ protected boolean treatMessage(NetworkEnvelope networkEnvelope, Connection conne
versions.log(protectedStoragePayload);
});

Set<PersistableNetworkPayload> persistableNetworkPayloadSet = dataResponse
.getPersistableNetworkPayloadSet();
if (persistableNetworkPayloadSet != null) {
persistableNetworkPayloadSet.forEach(persistableNetworkPayload -> {
dataResponse.getPersistableNetworkPayloadSet().forEach(persistableNetworkPayload -> {
// memorize message hashes
//Byte[] bytes = new Byte[persistableNetworkPayload.getHash().length];
//Arrays.setAll(bytes, n -> persistableNetworkPayload.getHash()[n]);

// memorize message hashes
//Byte[] bytes = new Byte[persistableNetworkPayload.getHash().length];
//Arrays.setAll(bytes, n -> persistableNetworkPayload.getHash()[n]);
//hashes.add(bytes);

//hashes.add(bytes);

hashes.add(persistableNetworkPayload.getHash());
});
}
hashes.add(persistableNetworkPayload.getHash());
});

bucketsPerHost.put(connection.getPeersNodeAddressProperty().getValue(), result);
versionBucketsPerHost.put(connection.getPeersNodeAddressProperty().getValue(), versions);
Expand Down
19 changes: 7 additions & 12 deletions monitor/src/main/java/bisq/monitor/metric/P2PSeedNodeSnapshot.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,20 +333,15 @@ protected boolean treatMessage(NetworkEnvelope networkEnvelope, Connection conne
result.log(protectedStoragePayload);
});

Set<PersistableNetworkPayload> persistableNetworkPayloadSet = dataResponse
.getPersistableNetworkPayloadSet();
if (persistableNetworkPayloadSet != null) {
persistableNetworkPayloadSet.forEach(persistableNetworkPayload -> {
dataResponse.getPersistableNetworkPayloadSet().forEach(persistableNetworkPayload -> {
// memorize message hashes
//Byte[] bytes = new Byte[persistableNetworkPayload.getHash().length];
//Arrays.setAll(bytes, n -> persistableNetworkPayload.getHash()[n]);

// memorize message hashes
//Byte[] bytes = new Byte[persistableNetworkPayload.getHash().length];
//Arrays.setAll(bytes, n -> persistableNetworkPayload.getHash()[n]);
//hashes.add(bytes);

//hashes.add(bytes);

hashes.add(persistableNetworkPayload.getHash());
});
}
hashes.add(persistableNetworkPayload.getHash());
});

bucketsPerHost.put(connection.getPeersNodeAddressProperty().getValue(), result);
return true;
Expand Down
18 changes: 9 additions & 9 deletions p2p/src/main/java/bisq/network/p2p/P2PService.java
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ public void onBroadcastFailed(String errorMessage) {
// to the logic from BroadcastHandler.sendToPeer
}
};
boolean result = p2PDataStorage.addProtectedStorageEntry(protectedMailboxStorageEntry, networkNode.getNodeAddress(), listener, true);
boolean result = p2PDataStorage.addProtectedStorageEntry(protectedMailboxStorageEntry, networkNode.getNodeAddress(), listener);
if (!result) {
sendMailboxMessageListener.onFault("Data already exists in our local database");

Expand Down Expand Up @@ -760,7 +760,7 @@ private void delayedRemoveEntryFromMailbox(DecryptedMessageWithPubKey decryptedM
expirableMailboxStoragePayload,
keyRing.getSignatureKeyPair(),
receiversPubKey);
p2PDataStorage.remove(protectedMailboxStorageEntry, networkNode.getNodeAddress(), true);
p2PDataStorage.remove(protectedMailboxStorageEntry, networkNode.getNodeAddress());
} catch (CryptoException e) {
log.error("Signing at getDataWithSignedSeqNr failed. That should never happen.");
}
Expand All @@ -779,14 +779,14 @@ private void delayedRemoveEntryFromMailbox(DecryptedMessageWithPubKey decryptedM
///////////////////////////////////////////////////////////////////////////////////////////

public boolean addPersistableNetworkPayload(PersistableNetworkPayload payload, boolean reBroadcast) {
return p2PDataStorage.addPersistableNetworkPayload(payload, networkNode.getNodeAddress(), true, true, reBroadcast, false);
return p2PDataStorage.addPersistableNetworkPayload(payload, networkNode.getNodeAddress(), reBroadcast);
}

public boolean addProtectedStorageEntry(ProtectedStoragePayload protectedStoragePayload, boolean isDataOwner) {
public boolean addProtectedStorageEntry(ProtectedStoragePayload protectedStoragePayload) {
if (isBootstrapped()) {
try {
ProtectedStorageEntry protectedStorageEntry = p2PDataStorage.getProtectedStorageEntry(protectedStoragePayload, keyRing.getSignatureKeyPair());
return p2PDataStorage.addProtectedStorageEntry(protectedStorageEntry, networkNode.getNodeAddress(), null, isDataOwner);
return p2PDataStorage.addProtectedStorageEntry(protectedStorageEntry, networkNode.getNodeAddress(), null);
} catch (CryptoException e) {
log.error("Signing at getDataWithSignedSeqNr failed. That should never happen.");
return false;
Expand All @@ -796,11 +796,11 @@ public boolean addProtectedStorageEntry(ProtectedStoragePayload protectedStorage
}
}

public boolean refreshTTL(ProtectedStoragePayload protectedStoragePayload, boolean isDataOwner) {
public boolean refreshTTL(ProtectedStoragePayload protectedStoragePayload) {
if (isBootstrapped()) {
try {
RefreshOfferMessage refreshTTLMessage = p2PDataStorage.getRefreshTTLMessage(protectedStoragePayload, keyRing.getSignatureKeyPair());
return p2PDataStorage.refreshTTL(refreshTTLMessage, networkNode.getNodeAddress(), isDataOwner);
return p2PDataStorage.refreshTTL(refreshTTLMessage, networkNode.getNodeAddress());
} catch (CryptoException e) {
log.error("Signing at getDataWithSignedSeqNr failed. That should never happen.");
return false;
Expand All @@ -810,11 +810,11 @@ public boolean refreshTTL(ProtectedStoragePayload protectedStoragePayload, boole
}
}

public boolean removeData(ProtectedStoragePayload protectedStoragePayload, boolean isDataOwner) {
public boolean removeData(ProtectedStoragePayload protectedStoragePayload) {
if (isBootstrapped()) {
try {
ProtectedStorageEntry protectedStorageEntry = p2PDataStorage.getProtectedStorageEntry(protectedStoragePayload, keyRing.getSignatureKeyPair());
return p2PDataStorage.remove(protectedStorageEntry, networkNode.getNodeAddress(), isDataOwner);
return p2PDataStorage.remove(protectedStorageEntry, networkNode.getNodeAddress());
} catch (CryptoException e) {
log.error("Signing at getDataWithSignedSeqNr failed. That should never happen.");
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void cancel() {
///////////////////////////////////////////////////////////////////////////////////////////

public void broadcast(BroadcastMessage message, @Nullable NodeAddress sender, ResultHandler resultHandler,
@Nullable Listener listener, boolean isDataOwner) {
@Nullable Listener listener) {
this.message = message;
this.resultHandler = resultHandler;
this.listener = listener;
Expand All @@ -127,6 +127,8 @@ public void broadcast(BroadcastMessage message, @Nullable NodeAddress sender, Re
Collections.shuffle(connectedPeersList);
numPeers = connectedPeersList.size();
int delay = 50;

boolean isDataOwner = (sender != null) && sender.equals(networkNode.getNodeAddress());
if (!isDataOwner) {
// for not data owner (relay nodes) we send to max. 7 nodes and use a longer delay
numPeers = Math.min(7, connectedPeersList.size());
Expand Down
Loading