@@ -59,7 +59,6 @@ public BlockEvent getBlockEvent(long blockNum) throws Exception {
5959 blockEvent .setBlockId (block .getBlockId ());
6060 blockEvent .setParentId (block .getParentBlockId ());
6161 blockEvent .setSolidId (manager .getChainBaseManager ().getBlockIdByNum (solidNum ));
62- blockEvent .setBlockTime (block .getTimeStamp ());
6362 if (instance .isBlockLogTriggerEnable ()) {
6463 blockEvent .setBlockLogTriggerCapsule (getBlockLogTrigger (block , solidNum ));
6564 }
@@ -145,11 +144,45 @@ private List<ContractTrigger> parseLogs(Protocol.Transaction tx,
145144
146145 Map <String , String > addrMap = new HashMap <>();
147146 Map <String , SmartContractOuterClass .SmartContract .ABI > abiMap = new HashMap <>();
147+ parseLogs (logs , originAddress , addrMap , abiMap );
148148
149+ int index = 1 ;
149150 for (Protocol .TransactionInfo .Log log : logs ) {
150151
151152 byte [] contractAddress = TransactionTrace
152153 .convertToTronAddress (log .getAddress ().toByteArray ());
154+ String strContractAddress =
155+ ArrayUtils .isEmpty (contractAddress ) ? "" : StringUtil .encode58Check (contractAddress );
156+ SmartContractOuterClass .SmartContract .ABI abi = abiMap .get (strContractAddress );
157+ ContractTrigger event = new ContractTrigger ();
158+ String creatorAddr = addrMap .get (strContractAddress );
159+ String txId = Hex .toHexString (txInfo .getId ().toByteArray ());
160+ event .setUniqueId (txId + "_" + index );
161+ event .setTransactionId (txId );
162+ event .setContractAddress (strContractAddress );
163+ event .setOriginAddress (originAddress );
164+ event .setCallerAddress ("" );
165+ event .setCreatorAddress (StringUtils .isEmpty (creatorAddr ) ? "" : creatorAddr );
166+ event .setBlockNumber (txInfo .getBlockNumber ());
167+ event .setTimeStamp (txInfo .getBlockTimeStamp ());
168+ event .setLogInfo (buildLogInfo (log ));
169+ event .setAbi (abi );
170+
171+ list .add (event );
172+ index ++;
173+ }
174+
175+ return list ;
176+ }
177+
178+ private void parseLogs (List <Protocol .TransactionInfo .Log > logs ,
179+ String originAddress ,
180+ Map <String , String > addrMap , Map <String ,
181+ SmartContractOuterClass .SmartContract .ABI > abiMap ) {
182+ for (Protocol .TransactionInfo .Log log : logs ) {
183+
184+ byte [] contractAddress = TransactionTrace
185+ .convertToTronAddress (log .getAddress ().toByteArray ());
153186 String strContractAddr =
154187 ArrayUtils .isEmpty (contractAddress ) ? "" : StringUtil .encode58Check (contractAddress );
155188 if (addrMap .get (strContractAddr ) != null ) {
@@ -175,34 +208,6 @@ private List<ContractTrigger> parseLogs(Protocol.Transaction tx,
175208 addrMap .put (strContractAddr , creatorAddr );
176209 abiMap .put (strContractAddr , abi );
177210 }
178-
179- int index = 1 ;
180- for (Protocol .TransactionInfo .Log log : logs ) {
181-
182- byte [] contractAddress = TransactionTrace
183- .convertToTronAddress (log .getAddress ().toByteArray ());
184- String strContractAddress =
185- ArrayUtils .isEmpty (contractAddress ) ? "" : StringUtil .encode58Check (contractAddress );
186- SmartContractOuterClass .SmartContract .ABI abi = abiMap .get (strContractAddress );
187- ContractTrigger event = new ContractTrigger ();
188- String creatorAddr = addrMap .get (strContractAddress );
189- String txId = Hex .toHexString (txInfo .getId ().toByteArray ());
190- event .setUniqueId (txId + "_" + index );
191- event .setTransactionId (txId );
192- event .setContractAddress (strContractAddress );
193- event .setOriginAddress (originAddress );
194- event .setCallerAddress ("" );
195- event .setCreatorAddress (StringUtils .isEmpty (creatorAddr ) ? "" : creatorAddr );
196- event .setBlockNumber (txInfo .getBlockNumber ());
197- event .setTimeStamp (txInfo .getBlockTimeStamp ());
198- event .setLogInfo (buildLogInfo (log ));
199- event .setAbi (abi );
200-
201- list .add (event );
202- index ++;
203- }
204-
205- return list ;
206211 }
207212
208213 private LogInfo buildLogInfo (Protocol .TransactionInfo .Log log ) {
0 commit comments