Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,12 @@ class LogFilterElement {
private final String[] topics;
@Getter
private final boolean removed;
@Getter
private final String blockTimestamp;

public LogFilterElement(String blockHash, Long blockNum, String txId, Integer txIndex,
String contractAddress, List<DataWord> topicList, String logData, int logIdx,
boolean removed) {
boolean removed, Long blockTimestamp) {
logIndex = ByteArray.toJsonHex(logIdx);
this.blockNumber = blockNum == null ? null : ByteArray.toJsonHex(blockNum);
this.blockHash = blockHash == null ? null : ByteArray.toJsonHex(blockHash);
Expand All @@ -477,6 +479,8 @@ public LogFilterElement(String blockHash, Long blockNum, String txId, Integer tx
topics[i] = ByteArray.toJsonHex(topicList.get(i).getData());
}
this.removed = removed;
this.blockTimestamp = blockTimestamp == null ? null
: ByteArray.toJsonHex(blockTimestamp / 1000);
}

@Override
Expand All @@ -500,12 +504,16 @@ public boolean equals(Object o) {
if (!Objects.equals(logIndex, item.logIndex)) {
return false;
}
return removed == item.removed;
if (removed != item.removed) {
return false;
}
return Objects.equals(blockTimestamp, item.blockTimestamp);
}

@Override
public int hashCode() {
return Objects.hash(blockHash, transactionHash, transactionIndex, logIndex, removed);
return Objects.hash(blockHash, transactionHash, transactionIndex,
logIndex, removed, blockTimestamp);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public static List<LogFilterElement> matchBlock(LogFilter logFilter, long blockN
topicList,
ByteArray.toHexString(log.getData().toByteArray()),
logIndexInBlock,
removed
removed,
transactionInfo.getBlockTimeStamp()
);
matchedLog.add(logFilterElement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static class TransactionLog {
private String data;
private String[] topics;
private boolean removed = false;
private String blockTimestamp;

public TransactionLog() {}
}
Expand Down Expand Up @@ -108,6 +109,7 @@ public TransactionReceipt(

// Set logs
List<TransactionLog> logList = new ArrayList<>();
String blockTimestamp = ByteArray.toJsonHex(txInfo.getBlockTimeStamp() / 1000);
for (int logIndex = 0; logIndex < txInfo.getLogCount(); logIndex++) {
TransactionInfo.Log log = txInfo.getLogList().get(logIndex);
TransactionLog transactionLog = new TransactionLog();
Expand All @@ -116,6 +118,7 @@ public TransactionReceipt(
transactionLog.setTransactionIndex(this.transactionIndex);
transactionLog.setBlockHash(this.blockHash);
transactionLog.setBlockNumber(this.blockNumber);
transactionLog.setBlockTimestamp(blockTimestamp);

byte[] addressByte = convertToTronAddress(log.getAddress().toByteArray());
transactionLog.setAddress(ByteArray.toJsonHexAddress(addressByte));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private TransactionInfo createTransactionInfo(byte[] address, byte[][] topicArra
LogInfo logInfo = new LogInfo(address, topics, data);
logList.add(LogInfo.buildLog(logInfo));
builder.addAllLog(logList);
builder.setBlockTimeStamp(1000000L);

return builder.build();
}
Expand Down Expand Up @@ -230,6 +231,8 @@ public void testMatchBlock() {
LogFilterElement logFilterElement1 = elementList.get(0);
LogFilterElement logFilterElement2 = elementList2.get(0);

Assert.assertEquals("0x3e8", logFilterElement1.getBlockTimestamp());
Assert.assertEquals("0x3e8", logFilterElement2.getBlockTimestamp());
Assert.assertEquals(logFilterElement1.hashCode(), logFilterElement2.hashCode());
Assert.assertEquals(logFilterElement1, logFilterElement2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public void testTransactionReceipt() throws JsonRpcInternalException {
Protocol.TransactionInfo transactionInfo = Protocol.TransactionInfo.newBuilder()
.setId(ByteString.copyFrom("1".getBytes()))
.setContractAddress(ByteString.copyFrom("address1".getBytes()))
.setBlockTimeStamp(1000000L)
.setReceipt(Protocol.ResourceReceipt.newBuilder()
.setEnergyUsageTotal(100L)
.setResult(Protocol.Transaction.Result.contractResult.DEFAULT)
Expand Down Expand Up @@ -90,6 +91,7 @@ public void testTransactionReceipt() throws JsonRpcInternalException {
Assert.assertEquals(transactionReceipt.getLogs()[0].getBlockNumber(), "0x1");
Assert.assertEquals(transactionReceipt.getLogs()[0].getTransactionHash(), "0x31");
Assert.assertEquals(transactionReceipt.getLogs()[0].getTransactionIndex(), "0x0");
Assert.assertEquals(transactionReceipt.getLogs()[0].getBlockTimestamp(), "0x3e8");

// assert default fields
Assert.assertNull(transactionReceipt.getRoot());
Expand Down
Loading