diff --git a/src/main/java/org/tron/core/net/node/NodeImpl.java b/src/main/java/org/tron/core/net/node/NodeImpl.java index b395d7b5591..5a3df3d3d0c 100644 --- a/src/main/java/org/tron/core/net/node/NodeImpl.java +++ b/src/main/java/org/tron/core/net/node/NodeImpl.java @@ -328,20 +328,24 @@ public void setPool(SyncPool pool) { } public void broadcast(Message msg) { - InventoryType type; - if (msg instanceof BlockMessage) { - logger.info("Ready to broadcast block {}", ((BlockMessage) msg).getBlockId()); - freshBlockId.offer(((BlockMessage) msg).getBlockId()); - BlockCache.put(msg.getMessageId(), (BlockMessage) msg); - type = InventoryType.BLOCK; - } else if (msg instanceof TransactionMessage) { - TrxCache.put(msg.getMessageId(), (TransactionMessage) msg); - type = InventoryType.TRX; - } else { - return; - } - synchronized (advObjToSpread) { - advObjToSpread.put(msg.getMessageId(), type); + try { + InventoryType type; + if (msg instanceof BlockMessage) { + logger.info("Ready to broadcast block {}", ((BlockMessage) msg).getBlockId()); + freshBlockId.offer(((BlockMessage) msg).getBlockId()); + BlockCache.put(msg.getMessageId(), (BlockMessage) msg); + type = InventoryType.BLOCK; + } else if (msg instanceof TransactionMessage) { + TrxCache.put(msg.getMessageId(), new TransactionMessage(msg.getData())); + type = InventoryType.TRX; + } else { + return; + } + synchronized (advObjToSpread) { + advObjToSpread.put(msg.getMessageId(), type); + } + } catch (Exception e) { + logger.error("Broadcast message failed, type: {}, reason: {}", msg.getType(), e.getMessage()); } }