added logging and added positive boolean to the fee waiting and unsigned fee events

This commit is contained in:
kennycud
2025-04-26 17:53:41 -07:00
parent 1f6ee72fc5
commit 17b2bf3848
5 changed files with 39 additions and 17 deletions

View File

@@ -432,7 +432,11 @@ public class CrossChainResource {
@ApiErrors({ApiError.INVALID_CRITERIA, ApiError.REPOSITORY_ISSUE}) @ApiErrors({ApiError.INVALID_CRITERIA, ApiError.REPOSITORY_ISSUE})
public List<ForeignFeeEncodedData> getUnsignedFees(@PathParam("address") String address) { public List<ForeignFeeEncodedData> getUnsignedFees(@PathParam("address") String address) {
return ForeignFeesManager.getInstance().getUnsignedFeesForAddress(address); List<ForeignFeeEncodedData> unsignedFeesForAddress = ForeignFeesManager.getInstance().getUnsignedFeesForAddress(address);
LOGGER.info("address = " + address);
LOGGER.info("returning unsigned = " + unsignedFeesForAddress);
return unsignedFeesForAddress;
} }
@GET @GET

View File

@@ -39,8 +39,10 @@ public class UnsignedFeesSocket extends ApiWebSocket implements Listener {
if (!(event instanceof FeeWaitingEvent)) if (!(event instanceof FeeWaitingEvent))
return; return;
for (Session session : getSessions()) for (Session session : getSessions()) {
sendUnsignedFeeEvent(session, new UnsignedFeeEvent()); boolean positive = ((FeeWaitingEvent) event).isPositive();
sendUnsignedFeeEvent(session, new UnsignedFeeEvent(positive));
}
} }

View File

@@ -258,7 +258,7 @@ public class ForeignFeesManager implements Listener {
this.needToBackupRequiredForeignFees.compareAndSet(false, true); this.needToBackupRequiredForeignFees.compareAndSet(false, true);
if( processLocalForeignFeesForCoin(((RequiredFeeUpdateEvent) event).getBitcoiny()) ) { if( processLocalForeignFeesForCoin(((RequiredFeeUpdateEvent) event).getBitcoiny()) ) {
EventBus.INSTANCE.notify(new FeeWaitingEvent()); EventBus.INSTANCE.notify(new FeeWaitingEvent(true));
} }
} }
// //
@@ -283,7 +283,7 @@ public class ForeignFeesManager implements Listener {
this.offersByAddress.computeIfAbsent( offer.qortalCreator, x -> new ArrayList<>()).add(offer); this.offersByAddress.computeIfAbsent( offer.qortalCreator, x -> new ArrayList<>()).add(offer);
if( processTradeOfferInWaiting(now, data) ) { if( processTradeOfferInWaiting(now, data) ) {
EventBus.INSTANCE.notify(new FeeWaitingEvent()); EventBus.INSTANCE.notify(new FeeWaitingEvent(true));
} }
} }
else { else {
@@ -451,6 +451,10 @@ public class ForeignFeesManager implements Listener {
// now that this fee has been processed, remove it from the process queue // now that this fee has been processed, remove it from the process queue
foreignFeesToRemove.add(foreignFeeToImport); foreignFeesToRemove.add(foreignFeeToImport);
} }
if( this.unsignedByAT.isEmpty() ) {
EventBus.INSTANCE.notify(new FeeWaitingEvent(false));
}
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Repository issue while verifying foreign fees", e); LOGGER.error("Repository issue while verifying foreign fees", e);
} finally { } finally {
@@ -698,7 +702,7 @@ public class ForeignFeesManager implements Listener {
} }
if( feeSignaturesNeeded ) { if( feeSignaturesNeeded ) {
EventBus.INSTANCE.notify(new FeeWaitingEvent()); EventBus.INSTANCE.notify(new FeeWaitingEvent(true));
} }
} }
@@ -860,7 +864,9 @@ public class ForeignFeesManager implements Listener {
fee fee
); );
LOGGER.info("updating unsigned");
this.unsignedByAT.put(atAddress, feeData); this.unsignedByAT.put(atAddress, feeData);
LOGGER.info("updated unsigned = " + this.unsignedByAT);
} }
// Network handlers // Network handlers

View File

@@ -5,4 +5,17 @@ import javax.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class UnsignedFeeEvent { public class UnsignedFeeEvent {
private boolean positive;
public UnsignedFeeEvent() {
}
public UnsignedFeeEvent(boolean positive) {
this.positive = positive;
}
public boolean isPositive() {
return positive;
}
} }

View File

@@ -5,22 +5,19 @@ import javax.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class FeeWaitingEvent implements Event{ public class FeeWaitingEvent implements Event{
private long timestamp;
private String address; private boolean positive;
public FeeWaitingEvent() { public FeeWaitingEvent() {
} }
public FeeWaitingEvent(long timestamp, String address) { public FeeWaitingEvent(boolean positive) {
this.timestamp = timestamp;
this.address = address; this.positive = positive;
} }
public long getTimestamp() { public boolean isPositive() {
return timestamp; return positive;
}
public String getAddress() {
return address;
} }
} }