mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-25 07:10:48 -04:00
Use currencyCode instead of locationKey
This commit is contained in:
parent
61012bf6f9
commit
745cba983d
1 changed files with 11 additions and 12 deletions
|
@ -93,7 +93,7 @@ class TomP2POfferRepository implements OfferRepository {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
writeInvalidationTimestampToDHT(locationKey);
|
writeInvalidationTimestampToDHT(offer.getCurrency().getCurrencyCode());
|
||||||
log.trace("Add offer to DHT was successful. Added data: [locationKey: " + locationKey +
|
log.trace("Add offer to DHT was successful. Added data: [locationKey: " + locationKey +
|
||||||
", value: " + offerData + "]");
|
", value: " + offerData + "]");
|
||||||
});
|
});
|
||||||
|
@ -145,7 +145,7 @@ class TomP2POfferRepository implements OfferRepository {
|
||||||
log.error("Remove offer from DHT failed. Error: " + e.getMessage());
|
log.error("Remove offer from DHT failed. Error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
writeInvalidationTimestampToDHT(locationKey);
|
writeInvalidationTimestampToDHT(offer.getCurrency().getCurrencyCode());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,10 +224,10 @@ class TomP2POfferRepository implements OfferRepository {
|
||||||
// Polling
|
// Polling
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void writeInvalidationTimestampToDHT(Number160 locationKey) {
|
private void writeInvalidationTimestampToDHT(String currencyCode) {
|
||||||
invalidationTimestamp.set(System.currentTimeMillis());
|
invalidationTimestamp.set(System.currentTimeMillis());
|
||||||
try {
|
try {
|
||||||
FuturePut putFuture = p2pNode.putData(getInvalidatedLocationKey(locationKey),
|
FuturePut putFuture = p2pNode.putData(getInvalidatedLocationKey(currencyCode),
|
||||||
new Data(invalidationTimestamp.get()));
|
new Data(invalidationTimestamp.get()));
|
||||||
putFuture.addListener(new BaseFutureListener<BaseFuture>() {
|
putFuture.addListener(new BaseFutureListener<BaseFuture>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -254,13 +254,12 @@ class TomP2POfferRepository implements OfferRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestInvalidationTimeStampFromDHT(String currencyCode) {
|
public void requestInvalidationTimeStampFromDHT(String currencyCode) {
|
||||||
Number160 locationKey = Number160.createHash(currencyCode);
|
FutureGet futureGet = p2pNode.getData(getInvalidatedLocationKey(currencyCode));
|
||||||
FutureGet getFuture = p2pNode.getData(getInvalidatedLocationKey(locationKey));
|
futureGet.addListener(new BaseFutureListener<BaseFuture>() {
|
||||||
getFuture.addListener(new BaseFutureListener<BaseFuture>() {
|
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(BaseFuture future) throws Exception {
|
public void operationComplete(BaseFuture future) throws Exception {
|
||||||
if (future.isSuccess()) {
|
if (future.isSuccess()) {
|
||||||
Data data = getFuture.data();
|
Data data = futureGet.data();
|
||||||
if (data != null && data.object() instanceof Long) {
|
if (data != null && data.object() instanceof Long) {
|
||||||
final Object object = data.object();
|
final Object object = data.object();
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
|
@ -273,12 +272,12 @@ class TomP2POfferRepository implements OfferRepository {
|
||||||
log.error("Get invalidationTimestamp from DHT failed. Data = " + data);
|
log.error("Get invalidationTimestamp from DHT failed. Data = " + data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (getFuture.data() == null) {
|
else if (futureGet.data() == null) {
|
||||||
// OK as nothing is set at the moment
|
// OK as nothing is set at the moment
|
||||||
// log.trace("Get invalidationTimestamp from DHT returns null. That is ok for the startup.");
|
// log.trace("Get invalidationTimestamp from DHT returns null. That is ok for the startup.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.error("Get invalidationTimestamp from DHT failed with reason:" + getFuture.failedReason());
|
log.error("Get invalidationTimestamp from DHT failed with reason:" + futureGet.failedReason());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +289,7 @@ class TomP2POfferRepository implements OfferRepository {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Number160 getInvalidatedLocationKey(Number160 locationKey) {
|
private Number160 getInvalidatedLocationKey(String currencyCode) {
|
||||||
return Number160.createHash(locationKey + "invalidated");
|
return Number160.createHash(currencyCode + "lastChangeTimestamp");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue