Skip to content
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

Cleanup discovery provider data contracts code from libs #21

Merged
merged 1 commit into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions libs/src/services/dataContracts/discoveryProviderFactoryClient.js

This file was deleted.

57 changes: 0 additions & 57 deletions libs/src/services/dataContracts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const Utils = require('../../utils')
const RegistryClient = require('./registryClient')
const UserFactoryClient = require('./userFactoryClient')
const TrackFactoryClient = require('./trackFactoryClient')
const DiscoveryProviderFactoryClient = require('./discoveryProviderFactoryClient')
const SocialFeatureFactoryClient = require('./socialFeatureFactoryClient')
const PlaylistFactoryClient = require('./playlistFactoryClient')
const UserLibraryFactoryClient = require('./userLibraryFactoryClient')
Expand All @@ -15,7 +14,6 @@ const IPLDBlacklistFactoryClient = require('./IPLDBlacklistFactoryClient')
const RegistryABI = Utils.importDataContractABI('Registry.json').abi
const UserFactoryABI = Utils.importDataContractABI('UserFactory.json').abi
const TrackFactoryABI = Utils.importDataContractABI('TrackFactory.json').abi
const DiscoveryProviderFactoryABI = Utils.importDataContractABI('DiscoveryProviderFactory.json').abi
const SocialFeatureFactoryABI = Utils.importDataContractABI('SocialFeatureFactory.json').abi
const PlaylistFactoryABI = Utils.importDataContractABI('PlaylistFactory.json').abi
const UserLibraryFactoryABI = Utils.importDataContractABI('UserLibraryFactory.json').abi
Expand All @@ -24,7 +22,6 @@ const IPLDBlacklistFactoryABI = Utils.importDataContractABI('IPLDBlacklistFactor
// define contract registry keys
const UserFactoryRegistryKey = 'UserFactory'
const TrackFactoryRegistryKey = 'TrackFactory'
const DiscoveryProviderFactoryRegistryKey = 'DiscoveryProviderFactory'
const SocialFeatureFactoryRegistryKey = 'SocialFeatureFactory'
const PlaylistFactoryRegistryKey = 'PlaylistFactory'
const UserLibraryFactoryRegistryKey = 'UserLibraryFactory'
Expand Down Expand Up @@ -64,14 +61,6 @@ class AudiusContracts {
)
this.clients.push(this.TrackFactoryClient)

this.DiscoveryProviderFactoryClient = new DiscoveryProviderFactoryClient(
this.web3Manager,
DiscoveryProviderFactoryABI,
DiscoveryProviderFactoryRegistryKey,
this.getRegistryAddressForContract
)
this.clients.push(this.DiscoveryProviderFactoryClient)

this.SocialFeatureFactoryClient = new SocialFeatureFactoryClient(
this.web3Manager,
SocialFeatureFactoryABI,
Expand Down Expand Up @@ -131,52 +120,6 @@ class AudiusContracts {
}
return contractRegistryKey
}

/**
* Registers a discovery service endpoint if it's not currently in the blockchain
* If it is already registered, returns id of the endpoint from the contract
* @param {string} endpoint fully qualified domain name of discprov endpoint
* @param {Boolean} validateEndpointHealth
*/
async registerDiscoveryProviderOnChain (endpoint, validateEndpointHealth = true) {
let listOfProviders = await this.DiscoveryProviderFactoryClient.getDiscoveryProviderList()
for (var i = 0; i < listOfProviders.length; i++) {
let parsedName = listOfProviders[i]
if (parsedName === endpoint) {
// Return discovery provider ID if already registered
return i + 1
}
}
if (!Utils.isFQDN(endpoint)) {
throw new Error('Not a fully qualified domain name!')
} else if (validateEndpointHealth && !(await Utils.isHealthy(endpoint))) {
throw new Error('Discovery provider failed health check. Provider could not be registered.')
} else {
return this.DiscoveryProviderFactoryClient.register(endpoint)
}
}

/** TODO: REMOVE AS THIS IS DEPRECATED
* Need to select a discovery service for libs to make queries against */
async selectDiscoveryProviderToUse (idx) {
let discoveryProviders = await this.DiscoveryProviderFactoryClient.getDiscoveryProviderList()

// on chain the discprov count starts at 1, not 0, but the list of discovery providers
// starts at index 0, so the index refers to the on chain
// discovery provider id, not the index from the list of discovery providers
if (discoveryProviders && discoveryProviders.length >= 1) {
let offsetIdx = idx - 1
let discoveryProviderEndpoint
if (idx && idx >= 1 && discoveryProviders[offsetIdx]) {
discoveryProviderEndpoint = discoveryProviders[offsetIdx]
} else {
discoveryProviderEndpoint = discoveryProviders[1]
}
return discoveryProviderEndpoint
} else {
throw new Error('Cannot register discovery provider, not enough providers available')
}
}
}

module.exports = AudiusContracts
72 changes: 0 additions & 72 deletions libs/tests/discoveryProviderClientTest.js

This file was deleted.

1 change: 0 additions & 1 deletion libs/tests/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require('./helpers')
require('./discoveryProviderClientTest')
require('./registryClientTest')
require('./userClientTest')
require('./creatorNodeTest')
Expand Down