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:
parent
7562d9bbf8
commit
b651eae258
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user