-
Notifications
You must be signed in to change notification settings - Fork 132
Fix primarySyncFromSecondary circular dep by moving initAudiusLibs to separate file
#3506
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
Closed
SidSethi
wants to merge
2
commits into
ss-dsr-findsyncrequest-metric-v2
from
ss-fix-primarysyncfromsecondary-serviceregistry
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| const { libs: AudiusLibs } = require('@audius/sdk') | ||
|
|
||
| const config = require('../config') | ||
| const { logger: genericLogger } = require('../logging') | ||
|
|
||
| /** | ||
| * Creates, initializes, and returns an audiusLibs instance | ||
| * | ||
| * Configures dataWeb3 to be internal to libs, logged in with delegatePrivateKey in order to write chain TX | ||
| */ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function is moved from
|
||
| module.exports = async (logger = genericLogger) => { | ||
| /** | ||
| * Define all config variables | ||
| */ | ||
| const ethProviderUrl = config.get('ethProviderUrl') | ||
| const ethNetworkId = config.get('ethNetworkId') | ||
| const discoveryProviderWhitelistConfig = config.get( | ||
| 'discoveryProviderWhitelist' | ||
| ) | ||
| const identityService = config.get('identityService') | ||
| const discoveryNodeUnhealthyBlockDiff = config.get( | ||
| 'discoveryNodeUnhealthyBlockDiff' | ||
| ) | ||
| const ethTokenAddress = config.get('ethTokenAddress') | ||
| const ethRegistryAddress = config.get('ethRegistryAddress') | ||
| const ethOwnerWallet = config.get('ethOwnerWallet') | ||
| const dataRegistryAddress = config.get('dataRegistryAddress') | ||
| const dataProviderUrl = config.get('dataProviderUrl') | ||
| const delegatePrivateKey = config.get('delegatePrivateKey') | ||
| const creatorNodeIsDebug = config.get('creatorNodeIsDebug') | ||
|
|
||
| const discoveryProviderWhitelist = discoveryProviderWhitelistConfig | ||
| ? new Set(discoveryProviderWhitelistConfig.split(',')) | ||
| : null | ||
|
|
||
| /** | ||
| * Configure ethWeb3 | ||
| */ | ||
| const ethWeb3 = await AudiusLibs.Utils.configureWeb3( | ||
| ethProviderUrl, | ||
| ethNetworkId, | ||
| /* requiresAccount */ false | ||
| ) | ||
| if (!ethWeb3) { | ||
| throw new Error( | ||
| 'Failed to init audiusLibs due to ethWeb3 configuration error' | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Create AudiusLibs instance | ||
| */ | ||
| const audiusLibs = new AudiusLibs({ | ||
| ethWeb3Config: AudiusLibs.configEthWeb3( | ||
| ethTokenAddress, | ||
| ethRegistryAddress, | ||
| ethWeb3, | ||
| ethOwnerWallet | ||
| ), | ||
| web3Config: AudiusLibs.configInternalWeb3( | ||
| dataRegistryAddress, | ||
| // pass as array | ||
| [dataProviderUrl], | ||
| // TODO - formatting this private key here is not ideal | ||
| delegatePrivateKey.replace('0x', '') | ||
| ), | ||
| discoveryProviderConfig: { | ||
| whitelist: discoveryProviderWhitelist, | ||
| unhealthyBlockDiff: discoveryNodeUnhealthyBlockDiff | ||
| }, | ||
| // If an identity service config is present, set up libs with the connection, otherwise do nothing | ||
| identityServiceConfig: identityService | ||
| ? AudiusLibs.configIdentityService(identityService) | ||
| : undefined, | ||
| isDebug: creatorNodeIsDebug, | ||
| isServer: true, | ||
| preferHigherPatchForPrimary: true, | ||
| preferHigherPatchForSecondaries: true, | ||
| logger | ||
| }) | ||
|
|
||
| await audiusLibs.init() | ||
| return audiusLibs | ||
| } | ||
Oops, something went wrong.
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.
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.
prevent name collision