cic-chain-events/cmd/filters.go
Mohammed Sohail f29e2a9ce7
feat: rpc block fetcher, move filters to internal
* move filters to internal folder
* rpc block fetcher
* add benchmarks:

goos: linux
goarch: amd64
pkg: github.com/grassrootseconomics/cic-chain-events/pkg/fetch
cpu: AMD EPYC Processor
Benchmark_RPC
Benchmark_RPC/RPC_Block_Fetcher_Benchmark
Benchmark_RPC/RPC_Block_Fetcher_Benchmark-4                   25          46000646 ns/op          221697 B/op        844 allocs/op
Benchmark_GraphQL
Benchmark_GraphQL/GraphQL_Block_Fetcher_Benchmark
Benchmark_GraphQL/GraphQL_Block_Fetcher_Benchmark-4           56          21219962 ns/op           56686 B/op         94 allocs/op
PASS
ok      github.com/grassrootseconomics/cic-chain-events/pkg/fetch       2.920s
2023-01-17 09:17:32 +00:00

37 lines
889 B
Go

package main
import (
"strings"
"sync"
"github.com/grassrootseconomics/cic-chain-events/internal/filter"
)
func initAddressFilter() filter.Filter {
// TODO: Bootstrap addresses from smart contract
// TODO: Add route to update cache
cache := &sync.Map{}
// Example bootstrap addresses
cache.Store(strings.ToLower("0x617f3112bf5397D0467D315cC709EF968D9ba546"), "USDT")
cache.Store(strings.ToLower("0x765DE816845861e75A25fCA122bb6898B8B1282a"), "cUSD")
cache.Store(strings.ToLower("0xD8763CBa276a3738E6DE85b4b3bF5FDed6D6cA73"), "cEUR")
return filter.NewAddressFilter(filter.AddressFilterOpts{
Cache: cache,
Logg: lo,
})
}
func initDecodeFilter() filter.Filter {
js, err := initJetStream()
if err != nil {
lo.Fatal("filters: critical error loading jetstream", "error", err)
}
return filter.NewDecodeFilter(filter.DecodeFilterOpts{
Logg: lo,
JSCtx: js,
})
}