-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addressing issue #41 - maxSyncConcurrency environment variable #63
base: master
Are you sure you want to change the base?
Conversation
This is a revised PR, same fix but cleared up some issues with the Dockerfile. |
indexer/indexer_test.go
Outdated
@@ -62,6 +62,7 @@ func TestIndexer_Pruning(t *testing.T) { | |||
Network: bitcoin.MainnetNetwork, | |||
Blockchain: bitcoin.Blockchain, | |||
}, | |||
MaxSyncConcurrency: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will default to 4 but will also cap out there. Might want set back to 256.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should explicitly handle this parsing error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handled in new commit.
Note: Allowed for MAXSYNC to not be set and default to 256
go.mod
Outdated
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove these extra lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
indexer/indexer.go
Outdated
@@ -229,6 +231,8 @@ func Initialize( | |||
coinCache: map[string]*types.AccountCoin{}, | |||
coinCacheMutex: new(sdkUtils.PriorityMutex), | |||
seenSemaphore: semaphore.NewWeighted(int64(runtime.NumCPU())), | |||
maxSync: config.MaxSyncConcurrency, | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
configuration/configuration.go
Outdated
@@ -180,6 +195,7 @@ func LoadConfiguration(baseDirectory string) (*Configuration, error) { | |||
} | |||
config.GenesisBlockIdentifier = bitcoin.TestnetGenesisBlockIdentifier | |||
config.Params = bitcoin.TestnetParams | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
README.md
Outdated
@@ -61,25 +70,25 @@ at port `8080`. | |||
|
|||
#### 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "MAXSYNC=256"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Dockerfile
Outdated
@@ -48,6 +48,7 @@ ENV GOLANG_VERSION 1.15.5 | |||
ENV GOLANG_DOWNLOAD_SHA256 9a58494e8da722c3aef248c9227b0e9c528c7318309827780f16220998180a0d | |||
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Dockerfile
Outdated
@@ -85,7 +86,6 @@ COPY --from=bitcoind-builder /app/bitcoind /app/bitcoind | |||
|
|||
# Copy binary from rosetta-builder | |||
COPY --from=rosetta-builder /app/* /app/ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: removed line unnecessarily
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added back in.
return nil, errors.New("syncer concurrency must be greater than zero") | ||
default: | ||
config.MaxSyncConcurrency = parsedValue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expression on line 148 is equivalent to:
!(err == nil || defaultMaxSync)
if we want to change.
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