Skip to content

Commit

Permalink
Add URSM flag to libs init for optimizely (#1333)
Browse files Browse the repository at this point in the history
  • Loading branch information
SidSethi committed Mar 22, 2021
1 parent 55d5802 commit 3b8a84d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion creator-node/src/serviceRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ class ServiceRegistry {
// If an identity service config is present, set up libs with the connection, otherwise do nothing
identityServiceConfig: identityService ? AudiusLibs.configIdentityService(identityService) : undefined,
isDebug: config.get('creatorNodeIsDebug'),
isServer: true
isServer: true,
enableUserReplicaSetManagerContract: true
})

await audiusLibs.init()
Expand Down
11 changes: 8 additions & 3 deletions libs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ class AudiusLibs {
comstockConfig,
captchaConfig,
isServer,
isDebug = false
isDebug = false,
enableUserReplicaSetManagerContract = false
}) {
// set version
this.version = packageJSON.version
Expand Down Expand Up @@ -209,6 +210,8 @@ class AudiusLibs {
this.Playlist = null
this.File = null

this.enableUserReplicaSetManagerContract = enableUserReplicaSetManagerContract

// Schemas
const schemaValidator = new SchemaValidator()
schemaValidator.init()
Expand Down Expand Up @@ -251,7 +254,7 @@ class AudiusLibs {
await this.web3Manager.init()
}

/** Contracts */
/** Contracts - Eth and Data Contracts */
let contractsToInit = []
if (this.ethWeb3Manager) {
this.ethContracts = new EthContracts(
Expand All @@ -268,7 +271,9 @@ class AudiusLibs {
this.contracts = new AudiusContracts(
this.web3Manager,
this.web3Config ? this.web3Config.registryAddress : null,
this.isServer)
this.isServer,
this.enableUserReplicaSetManagerContract
)
contractsToInit.push(this.contracts.init())
}
await Promise.all(contractsToInit)
Expand Down
8 changes: 7 additions & 1 deletion libs/src/services/dataContracts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const IPLDBlacklistFactoryRegistryKey = 'IPLDBlacklistFactory'
const UserReplicaSetManagerRegistryKey = 'UserReplicaSetManager'

class AudiusContracts {
constructor (web3Manager, registryAddress, isServer) {
constructor (web3Manager, registryAddress, isServer, enableUserReplicaSetManagerContract) {
this.web3Manager = web3Manager
this.registryAddress = registryAddress
this.isServer = isServer
Expand Down Expand Up @@ -93,6 +93,8 @@ class AudiusContracts {
this.UserLibraryFactoryClient,
this.IPLDBlacklistFactoryClient
]

this.enableUserReplicaSetManagerContract = enableUserReplicaSetManagerContract
}

async init () {
Expand All @@ -106,6 +108,10 @@ class AudiusContracts {
// Until the contract is deployed and added to the data contract registry, replica set
// operations will flow through the existing UserFactory
async initUserReplicaSetManagerClient (selectNewEndpointOnRetry = false) {
if (!this.enableUserReplicaSetManagerContract) {
return
}

try {
if (
this.UserReplicaSetManagerClient &&
Expand Down
3 changes: 2 additions & 1 deletion libs/tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const audiusLibsConfig = {
ethWeb3,
ethContractsConfig.ownerWallet
),
isServer: true
isServer: true,
enableUserReplicaSetManagerContract: true
}

async function initializeLibConfig (ownerWallet) {
Expand Down
3 changes: 2 additions & 1 deletion service-commands/src/libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ function LibsWrapper (walletIndex = 0) {
discoveryProviderConfig,
identityServiceConfig,
creatorNodeConfig,
isServer: true
isServer: true,
enableUserReplicaSetManagerContract: true
})

try {
Expand Down

0 comments on commit 3b8a84d

Please sign in to comment.