use of org.tron.core.net.message.TransactionMessage in project java-tron by tronprotocol.
the class Wallet method broadcastTransaction.
/**
* Broadcast a transaction.
*/
public boolean broadcastTransaction(Transaction signaturedTransaction) {
TransactionCapsule trx = new TransactionCapsule(signaturedTransaction);
try {
if (trx.validateSignature()) {
Message message = new TransactionMessage(signaturedTransaction);
dbManager.pushTransactions(trx);
p2pnode.broadcast(message);
return true;
}
} catch (ValidateSignatureException e) {
logger.debug(e.getMessage(), e);
} catch (ContractValidateException e) {
logger.debug(e.getMessage(), e);
} catch (ContractExeException e) {
logger.debug(e.getMessage(), e);
} catch (Exception e) {
logger.debug(e.getMessage(), e);
}
return false;
}
use of org.tron.core.net.message.TransactionMessage in project java-tron by tronprotocol.
the class NodeImpl method broadcast.
/**
* broadcast msg.
*
* @param msg msg to bradcast
*/
public void broadcast(Message msg) {
InventoryType type;
if (msg instanceof BlockMessage) {
logger.info("Ready to broadcast a block, Its hash is " + msg.getMessageId());
freshBlockId.offer(((BlockMessage) msg).getBlockId());
blockToAdvertise.add(((BlockMessage) msg).getBlockId());
type = InventoryType.BLOCK;
} else if (msg instanceof TransactionMessage) {
trxToAdvertise.add(msg.getMessageId());
type = InventoryType.TRX;
} else {
return;
}
// TODO: here need to cache fresh message to let peer fetch these data not from DB
advObjToSpread.put(msg.getMessageId(), type);
}
Aggregations