Addressing issue #41 - maxSyncConcurrency environment variable#63
Open
smeyerhot wants to merge 5 commits intocoinbase:masterfrom
Open
Addressing issue #41 - maxSyncConcurrency environment variable#63smeyerhot wants to merge 5 commits intocoinbase:masterfrom
smeyerhot wants to merge 5 commits intocoinbase:masterfrom
Conversation
Author
|
This is a revised PR, same fix but cleared up some issues with the Dockerfile. |
smeyerhot
commented
Dec 25, 2020
indexer/indexer_test.go
Outdated
| Network: bitcoin.MainnetNetwork, | ||
| Blockchain: bitcoin.Blockchain, | ||
| }, | ||
| MaxSyncConcurrency: 1, |
Author
There was a problem hiding this comment.
This will default to 4 but will also cap out there. Might want set back to 256.
configuration/configuration.go
Outdated
| case "0": | ||
| return nil, errors.New("syncer concurrency must be greater than zero") | ||
| default: | ||
| config.MaxSyncConcurrency, _ = strconv.ParseInt(maxSyncValue, 10, 64) |
Contributor
There was a problem hiding this comment.
you should explicitly handle this parsing error
Author
There was a problem hiding this comment.
Handled in new commit.
Note: Allowed for MAXSYNC to not be set and default to 256
go.mod
Outdated
|
|
||
|
|
||
|
|
||
|
|
Contributor
There was a problem hiding this comment.
remove these extra lines
indexer/indexer.go
Outdated
| coinCacheMutex: new(sdkUtils.PriorityMutex), | ||
| seenSemaphore: semaphore.NewWeighted(int64(runtime.NumCPU())), | ||
| maxSync: config.MaxSyncConcurrency, | ||
|
|
configuration/configuration.go
Outdated
| } | ||
| config.GenesisBlockIdentifier = bitcoin.TestnetGenesisBlockIdentifier | ||
| config.Params = bitcoin.TestnetParams | ||
|
|
README.md
Outdated
| #### Mainnet:Online | ||
| ```text | ||
| docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/bitcoin-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 8333:8333 rosetta-bitcoin:latest | ||
| docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/bitcoin-data:/data" -e "MAXSYNC"="256" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 8333:8333 rosetta-bitcoin:latest |
Dockerfile
Outdated
| ENV GOLANG_DOWNLOAD_SHA256 9a58494e8da722c3aef248c9227b0e9c528c7318309827780f16220998180a0d | ||
| ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz | ||
|
|
||
|
|
|
|
||
| # Copy binary from rosetta-builder | ||
| COPY --from=rosetta-builder /app/* /app/ | ||
|
|
Contributor
There was a problem hiding this comment.
nit: removed line unnecessarily
smeyerhot
commented
Jan 5, 2021
| return nil, errors.New("syncer concurrency must be greater than zero") | ||
| default: | ||
| config.MaxSyncConcurrency = parsedValue | ||
| } |
Author
There was a problem hiding this comment.
The expression on line 148 is equivalent to:
!(err == nil || defaultMaxSync)
if we want to change.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #41
Motivation
This commit allows users to specify an env variable MAXSYNC which overrides DefaultConcurrency in rosetta-sdk-go.
Solution
The solution was to add a field to the Configuration struct in the same way as Mode and Network. Then used this value when constructing the syncer to override defaults.
Open questions