This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
- Loading branch information
Alan Shaw
authored
Apr 12, 2019
1 parent
4376121
commit 2470be8
Showing
10 changed files
with
140 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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 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 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,34 @@ | ||
'use strict' | ||
|
||
const { TieredDatastore } = require('datastore-core') | ||
const get = require('dlv') | ||
|
||
const PubsubDatastore = require('./pubsub-datastore') | ||
const OfflineDatastore = require('./offline-datastore') | ||
|
||
module.exports = (ipfs) => { | ||
// Setup online routing for IPNS with a tiered routing composed by a DHT and a Pubsub router (if properly enabled) | ||
const ipnsStores = [] | ||
|
||
// Add IPNS pubsub if enabled | ||
let pubsubDs | ||
if (get(ipfs._options, 'EXPERIMENTAL.ipnsPubsub', false)) { | ||
const pubsub = ipfs.libp2p.pubsub | ||
const localDatastore = ipfs._repo.datastore | ||
const peerId = ipfs._peerInfo.id | ||
|
||
pubsubDs = new PubsubDatastore(pubsub, localDatastore, peerId) | ||
ipnsStores.push(pubsubDs) | ||
} | ||
|
||
// DHT should not be added as routing if we are offline or it is disabled | ||
if (get(ipfs._options, 'offline') || !get(ipfs._options, 'libp2p.dht.enabled', false)) { | ||
const offlineDatastore = new OfflineDatastore(ipfs._repo) | ||
ipnsStores.push(offlineDatastore) | ||
} else { | ||
ipnsStores.push(ipfs.libp2p.dht) | ||
} | ||
|
||
// Create ipns routing with a set of datastores | ||
return new TieredDatastore(ipnsStores) | ||
} |
This file contains 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 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 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 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 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 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 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