3
0
mirror of https://github.com/Qortal/qortal.git synced 2025-02-14 11:15:49 +00:00

Notify EventBus with NewTransactionEvent in Controller.onNewTransaction

This commit is contained in:
catbref 2020-12-01 17:23:10 +00:00
parent 7562d9bbf8
commit b651eae258

View File

@ -1036,12 +1036,27 @@ public class Controller extends Thread {
}
}
public static class NewTransactionEvent implements Event {
private final TransactionData transactionData;
public NewTransactionEvent(TransactionData transactionData) {
this.transactionData = transactionData;
}
public TransactionData getTransactionData() {
return this.transactionData;
}
}
/** Callback for when we've received a new transaction via API or peer. */
public void onNewTransaction(TransactionData transactionData, Peer peer) {
this.callbackExecutor.execute(() -> {
// Notify all peers (except maybe peer that sent it to us if applicable)
Network.getInstance().broadcast(broadcastPeer -> broadcastPeer == peer ? null : new TransactionSignaturesMessage(Arrays.asList(transactionData.getSignature())));
// Notify listeners
EventBus.INSTANCE.notify(new NewTransactionEvent(transactionData));
// If this is a CHAT transaction, there may be extra listeners to notify
if (transactionData.getType() == TransactionType.CHAT)
ChatNotifier.getInstance().onNewChatTransaction((ChatTransactionData) transactionData);