forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ethereum#54 from OffchainLabs/bloom
initial: bloom filters
- Loading branch information
Showing
5 changed files
with
104 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package arbitrum | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/ethereum/go-ethereum/eth" | ||
) | ||
|
||
const ( | ||
// bloomServiceThreads is the number of goroutines used globally by an Ethereum | ||
// instance to service bloombits lookups for all running filters. | ||
bloomServiceThreads = 16 | ||
|
||
// bloomFilterThreads is the number of goroutines used locally per filter to | ||
// multiplex requests onto the global servicing goroutines. | ||
bloomFilterThreads = 3 | ||
|
||
// bloomRetrievalBatch is the maximum number of bloom bit retrievals to service | ||
// in a single batch. | ||
bloomRetrievalBatch = 16 | ||
|
||
// bloomRetrievalWait is the maximum time to wait for enough bloom bit requests | ||
// to accumulate request an entire batch (avoiding hysteresis). | ||
bloomRetrievalWait = time.Duration(0) | ||
) | ||
|
||
// startBloomHandlers starts a batch of goroutines to accept bloom bit database | ||
// retrievals from possibly a range of filters and serving the data to satisfy. | ||
func (b *Backend) startBloomHandlers(sectionSize uint64) { | ||
for i := 0; i < bloomServiceThreads; i++ { | ||
go func() { | ||
for { | ||
select { | ||
case _, more := <-b.chanClose: | ||
if !more { | ||
return | ||
} | ||
case request := <-b.bloomRequests: | ||
task := <-request | ||
eth.ServeBloombitRetrieval(task, b.chainDb, sectionSize) | ||
request <- task | ||
} | ||
} | ||
}() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters