Skip to content

Commit

Permalink
fix get_logs error (#1423)
Browse files Browse the repository at this point in the history
  • Loading branch information
hero5512 authored Jan 11, 2023
1 parent 7eea502 commit 98a1b05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/store/ledgerstore/block_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ func (this *BlockStore) LoadBloomBits() error {

initStart := (curBlockHeight + 4095) / 4096
if curBlockHeight < config.GetAddDecimalsHeight() {
initStart = config.GetAddDecimalsHeight() / 4096 * 4096
initStart = MinFilterStart()
}

start, err := GetOrSetFilterStart(this.store, initStart)
Expand All @@ -602,3 +602,7 @@ func (this *BlockStore) LoadBloomBits() error {
}
return nil
}

func MinFilterStart() uint32 {
return config.GetAddDecimalsHeight() / 4096 * 4096
}
9 changes: 9 additions & 0 deletions http/ethrpc/filters/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/eth/filters"
common2 "github.com/ontio/ontology/common"
common4 "github.com/ontio/ontology/core/store/common"
"github.com/ontio/ontology/core/store/ledgerstore"
"github.com/ontio/ontology/core/types"
"github.com/ontio/ontology/http/base/actor"
utils2 "github.com/ontio/ontology/http/ethrpc/utils"
Expand Down Expand Up @@ -142,6 +143,14 @@ func (f *Filter) Logs(ctx context.Context) ([]*ethtypes.Log, error) {
}

start := actor.GetFilterStart()
minFilterStart := ledgerstore.MinFilterStart()
if f.criteria.ToBlock.Int64() < int64(minFilterStart) {
return nil, nil
}

if f.criteria.FromBlock.Int64() < int64(minFilterStart) {
f.criteria.FromBlock = big.NewInt(int64(minFilterStart))
}

if f.criteria.FromBlock.Int64() < int64(start) ||
f.criteria.ToBlock.Int64() < int64(start) {
Expand Down

0 comments on commit 98a1b05

Please sign in to comment.