Skip to content

Commit

Permalink
Remove creator node IPFS env vars (#996)
Browse files Browse the repository at this point in the history
We have an override to fetch the IPFS announce address. However the better way to manage this is via IPFS directly as opposed to application configs. So removed the configs
  • Loading branch information
dmanjunath committed Oct 27, 2020
1 parent 8e5679b commit 12810c3
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 34 deletions.
5 changes: 0 additions & 5 deletions creator-node/compose/env/base.env
Expand Up @@ -20,11 +20,6 @@ serviceLatitude=
serviceLongitude=
serviceCountry=

# required when running with kubernetes, need to pass in the ip address of the instance that will run
# the ipfs node. should be done by default in audius manifests
# ipfsClusterIP=127.0.0.1
# ipfsClusterPort=0

# wallet information required on all environments
delegateOwnerWallet=
delegatePrivateKey=
Expand Down
5 changes: 0 additions & 5 deletions creator-node/docker-compose/development.env
Expand Up @@ -25,11 +25,6 @@ serviceLongitude=
serviceCountry=
userMetadataNodeUrl=http://docker.for.mac.localhost:4000

# required when running with kubernetes, need to pass in the ip address of the instance that will run
# the ipfs node. should be done by default in audius manifests
# ipfsClusterIP=127.0.0.1
# ipfsClusterPort=0

# wallet information required on all environments
delegateOwnerWallet=0x1eC723075E67a1a2B6969dC5CfF0C6793cb36D25
delegatePrivateKey=0xdb527e4d4a2412a443c17e1666764d3bba43e89e61129a35f9abc337ec170a5d
Expand Down
12 changes: 0 additions & 12 deletions creator-node/src/config.js
Expand Up @@ -40,18 +40,6 @@ const config = convict({
env: 'ipfsPort',
default: null
},
ipfsClusterIP: {
doc: 'The IP address of the node in the kube cluster running ipfs to expose it so outside nodes can peer into it',
format: 'ipaddress',
env: 'ipfsClusterIP',
default: '127.0.0.1' // somewhat of a hack because convict requires non-null values, will check for this value when used
},
ipfsClusterPort: {
doc: 'The port of the node in the kube cluster running ipfs to expose it so outside nodes can peer into it',
format: 'port',
env: 'ipfsClusterPort',
default: 0
},
storagePath: {
doc: 'File system path to store raw files that are uploaded',
format: String,
Expand Down
2 changes: 1 addition & 1 deletion creator-node/src/routes/files.js
Expand Up @@ -391,7 +391,7 @@ module.exports = function (app) {

app.get('/ipfs_peer_info', handleResponse(async (req, res) => {
const ipfs = req.app.get('ipfsAPI')
const ipfsIDObj = await getIPFSPeerId(ipfs, config)
const ipfsIDObj = await getIPFSPeerId(ipfs)
if (req.query.caller_ipfs_id) {
try {
req.logger.info(`Connection to ${req.query.caller_ipfs_id}`)
Expand Down
2 changes: 1 addition & 1 deletion creator-node/src/routes/nodeSync.js
Expand Up @@ -127,7 +127,7 @@ module.exports = function (app) {

// Expose ipfs node's peer ID.
const ipfs = req.app.get('ipfsAPI')
const ipfsIDObj = await getIPFSPeerId(ipfs, config)
const ipfsIDObj = await getIPFSPeerId(ipfs)

if (!dbOnlySync) {
// Rehydrate files if necessary
Expand Down
15 changes: 5 additions & 10 deletions creator-node/src/utils.js
Expand Up @@ -69,19 +69,14 @@ async function getFileUUIDForImageCID (req, imageCID) {
} else return null
}

async function getIPFSPeerId (ipfs, config) {
const ipfsClusterIP = config.get('ipfsClusterIP')
const ipfsClusterPort = config.get('ipfsClusterPort')
async function getIPFSPeerId (ipfs) {
// Assumes the ipfs id returns the correct address from IPFS. May need to set the correct values in
// the IPFS pod. Command is:
// ipfs config --json Addresses.Announce '["/ip4/<public ip>/tcp/<public port>"]'
// the public port is the port mapped to IPFS' port 4001

let ipfsIDObj = await ipfs.id()

// if it's a real host and port, generate a new ipfs id and override the addresses with this value
// if it's local or these variables aren't passed in, just return the regular ipfs.id() result
if (ipfsClusterIP && ipfsClusterPort !== null && ipfsClusterIP !== '127.0.0.1' && ipfsClusterPort !== 0) {
const addressStr = `/ip4/${ipfsClusterIP}/tcp/${ipfsClusterPort}/ipfs/${ipfsIDObj.id}`
ipfsIDObj.addresses = [addressStr]
}

return ipfsIDObj
}

Expand Down

0 comments on commit 12810c3

Please sign in to comment.