Skip to content

Commit 51de3ea

Browse files
committed
feat(jsonrpc): refactor to set min and max section
1 parent 9965edc commit 51de3ea

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

framework/src/main/java/org/tron/core/services/jsonrpc/filters/LogBlockQuery.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,21 @@ public LogBlockQuery(LogFilterWrapper logFilterWrapper, SectionBloomStore sectio
3939
this.currentMaxBlockNum = currentMaxBlockNum;
4040

4141
if (logFilterWrapper.getFromBlock() == Long.MAX_VALUE) {
42-
minSection = (int) (currentMaxBlockNum / Bloom.BLOOM_BIT_SIZE);
4342
minBlock = currentMaxBlockNum;
4443
} else {
45-
minSection = (int) (logFilterWrapper.getFromBlock() / Bloom.BLOOM_BIT_SIZE);
4644
minBlock = logFilterWrapper.getFromBlock();
4745
}
46+
minSection = (int) (minBlock / Bloom.BLOOM_BIT_SIZE);
4847

4948
if (logFilterWrapper.getToBlock() == Long.MAX_VALUE) {
50-
maxSection = (int) (currentMaxBlockNum / Bloom.BLOOM_BIT_SIZE);
5149
maxBlock = currentMaxBlockNum;
5250
} else {
53-
maxSection = (int) (logFilterWrapper.getToBlock() / Bloom.BLOOM_BIT_SIZE);
5451
maxBlock = logFilterWrapper.getToBlock();
5552
if (maxBlock > currentMaxBlockNum) {
5653
maxBlock = currentMaxBlockNum;
5754
}
5855
}
56+
maxSection = (int) (maxBlock / Bloom.BLOOM_BIT_SIZE);
5957
}
6058

6159
public List<Long> getPossibleBlock() throws ExecutionException, InterruptedException,
@@ -71,7 +69,7 @@ public List<Long> getPossibleBlock() throws ExecutionException, InterruptedExcep
7169
BitSet blockNumBitSet = new BitSet(capacity);
7270
blockNumBitSet.set(0, capacity);
7371

74-
//works serial
72+
// works serial
7573
for (int[][] conditionsIndex : allConditionsIndex) {
7674
BitSet bitSet = subMatch(conditionsIndex);
7775
blockNumBitSet.and(bitSet);

framework/src/main/java/org/tron/core/services/jsonrpc/filters/LogFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public LogFilter(FilterRequest fr) throws JsonRpcInvalidParamsException {
7070
if (fr.getTopics() != null) {
7171
//restrict depth of topics, because event has a signature and most 3 indexed parameters
7272
if (fr.getTopics().length > maxTopics) {
73-
throw new JsonRpcInvalidParamsException("topics size should be <= 4");
73+
throw new JsonRpcInvalidParamsException("topics size should be <= " + maxTopics);
7474
}
7575
for (Object topic : fr.getTopics()) {
7676
if (topic == null) {

0 commit comments

Comments
 (0)