github.com/Cleverse/go-ethereum@v0.0.0-20220927095127-45113064e7f2/arbitrum/bloom.go (about) 1 package arbitrum 2 3 import ( 4 "time" 5 6 "github.com/ethereum/go-ethereum/eth" 7 ) 8 9 const ( 10 // bloomServiceThreads is the number of goroutines used globally by an Ethereum 11 // instance to service bloombits lookups for all running filters. 12 bloomServiceThreads = 16 13 14 // bloomFilterThreads is the number of goroutines used locally per filter to 15 // multiplex requests onto the global servicing goroutines. 16 bloomFilterThreads = 3 17 18 // bloomRetrievalBatch is the maximum number of bloom bit retrievals to service 19 // in a single batch. 20 bloomRetrievalBatch = 16 21 22 // bloomRetrievalWait is the maximum time to wait for enough bloom bit requests 23 // to accumulate request an entire batch (avoiding hysteresis). 24 bloomRetrievalWait = time.Duration(0) 25 ) 26 27 // startBloomHandlers starts a batch of goroutines to accept bloom bit database 28 // retrievals from possibly a range of filters and serving the data to satisfy. 29 func (b *Backend) startBloomHandlers(sectionSize uint64) { 30 for i := 0; i < bloomServiceThreads; i++ { 31 go func() { 32 for { 33 select { 34 case _, more := <-b.chanClose: 35 if !more { 36 return 37 } 38 case request := <-b.bloomRequests: 39 task := <-request 40 eth.ServeBloombitRetrieval(task, b.chainDb, sectionSize) 41 request <- task 42 } 43 } 44 }() 45 } 46 }