mirror of
https://github.com/Qortal/qortal.git
synced 2025-04-24 03:47:52 +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. */
|
/** Callback for when we've received a new transaction via API or peer. */
|
||||||
public void onNewTransaction(TransactionData transactionData, Peer peer) {
|
public void onNewTransaction(TransactionData transactionData, Peer peer) {
|
||||||
this.callbackExecutor.execute(() -> {
|
this.callbackExecutor.execute(() -> {
|
||||||
// Notify all peers (except maybe peer that sent it to us if applicable)
|
// 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())));
|
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 this is a CHAT transaction, there may be extra listeners to notify
|
||||||
if (transactionData.getType() == TransactionType.CHAT)
|
if (transactionData.getType() == TransactionType.CHAT)
|
||||||
ChatNotifier.getInstance().onNewChatTransaction((ChatTransactionData) transactionData);
|
ChatNotifier.getInstance().onNewChatTransaction((ChatTransactionData) transactionData);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user