use of io.nuls.ledger.event.notice.BalanceChangeData in project nuls by nuls-io.
the class UtxoTransactionTool method sendNotice.
private void sendNotice(Balance oldBalance, Balance balance, String address) {
long oldNa = oldBalance.getBalance().getValue();
long change = balance.getBalance().getValue() - oldNa;
if (NulsContext.LOCAL_ADDRESS_LIST != null && NulsContext.LOCAL_ADDRESS_LIST.contains(address)) {
if (change == 0) {
return;
}
BalanceChangeNotice notice = new BalanceChangeNotice();
BalanceChangeData data = new BalanceChangeData();
data.setAddress(address);
data.setStatus(1);
if (change < 0) {
data.setType(1);
data.setAmount(Na.valueOf(0 - change));
} else {
data.setType(0);
data.setAmount(Na.valueOf(change));
}
notice.setEventBody(data);
if (eventBroadcaster == null) {
eventBroadcaster = NulsContext.getServiceBean(EventBroadcaster.class);
}
eventBroadcaster.publishToLocal(notice);
}
}
Aggregations