diff options
author | Zsolt Felfoldi <zsfelfoldi@gmail.com> | 2017-08-19 03:52:20 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-09-06 16:13:13 +0800 |
commit | 4ea4d2dc3473afd9d2eda6ef6b359accce1f0946 (patch) | |
tree | e651cfc2e3aa36083b333bf34dc3cccef2623f26 /eth/api_backend.go | |
parent | 1e67378df879b1ce566f17dd95a3b126056254b5 (diff) | |
download | dexon-4ea4d2dc3473afd9d2eda6ef6b359accce1f0946.tar.gz dexon-4ea4d2dc3473afd9d2eda6ef6b359accce1f0946.tar.zst dexon-4ea4d2dc3473afd9d2eda6ef6b359accce1f0946.zip |
core, eth: add bloombit indexer, filter based on it
Diffstat (limited to 'eth/api_backend.go')
-rw-r--r-- | eth/api_backend.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/eth/api_backend.go b/eth/api_backend.go index 19ef79f23..fa3cf3f80 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -28,6 +28,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/downloader" + "github.com/ethereum/go-ethereum/eth/filters" "github.com/ethereum/go-ethereum/eth/gasprice" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" @@ -194,3 +195,29 @@ func (b *EthApiBackend) EventMux() *event.TypeMux { func (b *EthApiBackend) AccountManager() *accounts.Manager { return b.eth.AccountManager() } + +func (b *EthApiBackend) GetBloomBits(ctx context.Context, bitIdx uint64, sectionIdxList []uint64) ([][]byte, error) { + results := make([][]byte, len(sectionIdxList)) + var err error + for i, sectionIdx := range sectionIdxList { + sectionHead := core.GetCanonicalHash(b.eth.chainDb, (sectionIdx+1)*bloomBitsSection-1) + results[i], err = core.GetBloomBits(b.eth.chainDb, bitIdx, sectionIdx, sectionHead) + if err != nil { + return nil, err + } + } + return results, nil +} + +func (b *EthApiBackend) BloomBitsSections() uint64 { + sections, _, _ := b.eth.bbIndexer.Sections() + return sections +} + +func (b *EthApiBackend) BloomBitsConfig() filters.BloomConfig { + return filters.BloomConfig{ + SectionSize: bloomBitsSection, + MaxRequestLen: 16, + MaxRequestWait: 0, + } +} |