synchronize access to account age witness maps to fix missing hash
This commit is contained in:
parent
5feb487039
commit
0372af663a
@ -244,8 +244,10 @@ public class AccountAgeWitnessService {
|
||||
|
||||
@VisibleForTesting
|
||||
public void addToMap(AccountAgeWitness accountAgeWitness) {
|
||||
synchronized (this) {
|
||||
accountAgeWitnessMap.putIfAbsent(accountAgeWitness.getHashAsByteArray(), accountAgeWitness);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -253,6 +255,7 @@ public class AccountAgeWitnessService {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void publishMyAccountAgeWitness(PaymentAccountPayload paymentAccountPayload) {
|
||||
synchronized (this) {
|
||||
AccountAgeWitness accountAgeWitness = getMyWitness(paymentAccountPayload);
|
||||
P2PDataStorage.ByteArray hash = accountAgeWitness.getHashAsByteArray();
|
||||
|
||||
@ -266,6 +269,7 @@ public class AccountAgeWitnessService {
|
||||
p2PService.addPersistableNetworkPayload(accountAgeWitness, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getPeerAccountAgeWitnessHash(Trade trade) {
|
||||
return findTradePeerWitness(trade)
|
||||
@ -318,6 +322,7 @@ public class AccountAgeWitnessService {
|
||||
|
||||
private Optional<AccountAgeWitness> getWitnessByHash(byte[] hash) {
|
||||
P2PDataStorage.ByteArray hashAsByteArray = new P2PDataStorage.ByteArray(hash);
|
||||
synchronized (this) {
|
||||
|
||||
// First we look up in our fast lookup cache
|
||||
if (accountAgeWitnessCache.containsKey(hashAsByteArray)) {
|
||||
@ -335,6 +340,7 @@ public class AccountAgeWitnessService {
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<AccountAgeWitness> getWitnessByHashAsHex(String hashAsHex) {
|
||||
return getWitnessByHash(Utilities.decodeFromHex(hashAsHex));
|
||||
@ -548,8 +554,8 @@ public class AccountAgeWitnessService {
|
||||
if (accountAgeWitnessOptional.isPresent()) {
|
||||
peersWitness = accountAgeWitnessOptional.get();
|
||||
} else {
|
||||
peersWitness = getNewWitness(peersPaymentAccountPayload, peersPubKeyRing);
|
||||
log.warn("We did not find the peers witness data. That is expected with peers using an older version.");
|
||||
peersWitness = getNewWitness(peersPaymentAccountPayload, peersPubKeyRing);
|
||||
}
|
||||
|
||||
// Check if date in witness is not older than the release date of that feature (was added in v0.6)
|
||||
|
@ -964,9 +964,7 @@ public class XmrWalletService {
|
||||
// -------------------------------- HELPERS -------------------------------
|
||||
|
||||
/**
|
||||
* Processes internally before notifying external listeners.
|
||||
*
|
||||
* TODO: no longer neccessary to execute on user thread?
|
||||
* Relays wallet notifications to external listeners.
|
||||
*/
|
||||
private class XmrWalletListener extends MoneroWalletListener {
|
||||
|
||||
|
@ -19,8 +19,6 @@ package bisq.core.payment;
|
||||
|
||||
import bisq.core.api.model.PaymentAccountForm;
|
||||
import bisq.core.api.model.PaymentAccountFormField;
|
||||
import bisq.core.api.model.PaymentAccountFormField.Component;
|
||||
import bisq.core.api.model.PaymentAccountFormField.FieldId;
|
||||
import bisq.core.locale.BankUtil;
|
||||
import bisq.core.locale.Country;
|
||||
import bisq.core.locale.CountryUtil;
|
||||
@ -335,7 +333,7 @@ public abstract class PaymentAccount implements PersistablePayload {
|
||||
* @param paymentAccountJsonString The json data representing a new payment account form.
|
||||
* @return A populated PaymentAccount subclass instance.
|
||||
*/
|
||||
public static PaymentAccount fromJson(String paymentAccountJsonString) {
|
||||
public static synchronized PaymentAccount fromJson(String paymentAccountJsonString) {
|
||||
Class<? extends PaymentAccount> clazz = getPaymentAccountClassFromJson(paymentAccountJsonString);
|
||||
Gson gson = gsonBuilder.registerTypeAdapter(clazz, new PaymentAccountTypeAdapter(clazz)).create();
|
||||
return gson.fromJson(paymentAccountJsonString, clazz);
|
||||
|
@ -79,9 +79,6 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
|
||||
}
|
||||
}
|
||||
|
||||
// ensure connected to monero network
|
||||
trade.checkWalletConnection();
|
||||
|
||||
// process payout tx unless already unlocked
|
||||
if (!trade.isPayoutUnlocked()) processPayoutTx(message);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user