log warning on failure to sign and publish peer account age witness
Some checks failed
CI / build (macos-13) (push) Has been cancelled
CI / build (ubuntu-22.04) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
Codacy Coverage Reporter / Publish coverage (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled

This commit is contained in:
woodser 2024-10-15 18:21:57 -04:00
parent 072401386e
commit a9c975466e
3 changed files with 11 additions and 11 deletions

View file

@ -737,14 +737,13 @@ public class AccountAgeWitnessService {
} }
public Optional<SignedWitness> traderSignAndPublishPeersAccountAgeWitness(Trade trade) { public Optional<SignedWitness> traderSignAndPublishPeersAccountAgeWitness(Trade trade) {
AccountAgeWitness peersWitness = findTradePeerWitness(trade).orElse(null);
BigInteger tradeAmount = trade.getAmount();
checkNotNull(trade.getTradePeer().getPubKeyRing(), "Peer must have a keyring"); checkNotNull(trade.getTradePeer().getPubKeyRing(), "Peer must have a keyring");
PublicKey peersPubKey = trade.getTradePeer().getPubKeyRing().getSignaturePubKey(); PublicKey peersPubKey = trade.getTradePeer().getPubKeyRing().getSignaturePubKey();
checkNotNull(peersWitness, "Not able to find peers witness, unable to sign for trade {}",
trade.toString());
checkNotNull(tradeAmount, "Trade amount must not be null");
checkNotNull(peersPubKey, "Peers pub key must not be null"); checkNotNull(peersPubKey, "Peers pub key must not be null");
AccountAgeWitness peersWitness = findTradePeerWitness(trade).orElse(null);
checkNotNull(peersWitness, "Not able to find peers witness, unable to sign for trade " + trade.toString());
BigInteger tradeAmount = trade.getAmount();
checkNotNull(tradeAmount, "Trade amount must not be null");
try { try {
return signedWitnessService.signAndPublishAccountAgeWitness(tradeAmount, peersWitness, peersPubKey); return signedWitnessService.signAndPublishAccountAgeWitness(tradeAmount, peersWitness, peersPubKey);

View file

@ -105,12 +105,9 @@ public class ProcessPaymentReceivedMessage extends TradeTask {
// advance state, arbitrator auto completes when payout published // advance state, arbitrator auto completes when payout published
trade.advanceState(Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG); trade.advanceState(Trade.State.SELLER_SENT_PAYMENT_RECEIVED_MSG);
// publish signed witness // buyer republishes signed witness for resilience
SignedWitness signedWitness = message.getBuyerSignedWitness(); SignedWitness signedWitness = message.getBuyerSignedWitness();
if (signedWitness != null && trade instanceof BuyerTrade) { if (signedWitness != null && trade instanceof BuyerTrade) {
// We received the signedWitness from the seller and publish the data to the network.
// The signer has published it as well but we prefer to re-do it on our side as well to achieve higher
// resilience.
processModel.getAccountAgeWitnessService().publishOwnSignedWitness(signedWitness); processModel.getAccountAgeWitnessService().publishOwnSignedWitness(signedWitness);
} }

View file

@ -90,8 +90,12 @@ public abstract class SellerSendPaymentReceivedMessage extends SendMailboxMessag
// sign account witness // sign account witness
AccountAgeWitnessService accountAgeWitnessService = processModel.getAccountAgeWitnessService(); AccountAgeWitnessService accountAgeWitnessService = processModel.getAccountAgeWitnessService();
if (accountAgeWitnessService.isSignWitnessTrade(trade)) { if (accountAgeWitnessService.isSignWitnessTrade(trade)) {
accountAgeWitnessService.traderSignAndPublishPeersAccountAgeWitness(trade).ifPresent(witness -> signedWitness = witness); try {
log.info("{} {} signed and published peers account age witness", trade.getClass().getSimpleName(), trade.getId()); accountAgeWitnessService.traderSignAndPublishPeersAccountAgeWitness(trade).ifPresent(witness -> signedWitness = witness);
log.info("{} {} signed and published peers account age witness", trade.getClass().getSimpleName(), trade.getId());
} catch (Exception e) {
log.warn("Failed to sign and publish peer's account age witness for {} {}, error={}\n", getClass().getSimpleName(), trade.getId(), e.getMessage(), e);
}
} }
// We do not use a real unique ID here as we want to be able to re-send the exact same message in case the // We do not use a real unique ID here as we want to be able to re-send the exact same message in case the