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.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ae1152
commit 7f51f8b
Showing
10 changed files
with
491 additions
and
222 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
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,42 @@ | ||
'use strict' | ||
|
||
// const { Key } = require('interface-datastore') | ||
// const { encodeBase32 } = require('./utils') | ||
|
||
// Dht datastore sets the proper encoding for storing records | ||
class DhtDatastore { | ||
constructor (dht) { | ||
this._dht = dht | ||
} | ||
|
||
/** | ||
* Put a value to the dht indexed by the received key properly encoded. | ||
* @param {Buffer} key identifier of the value. | ||
* @param {Buffer} value value to be stored. | ||
* @param {function(Error)} callback | ||
* @returns {void} | ||
*/ | ||
put (key, value, callback) { | ||
// encode key properly - base32(/ipns/{cid}) TODO: remove this | ||
// const routingKey = new Key('/' + encodeBase32(key), false) | ||
|
||
this._dht.put(key, value, callback) | ||
// this._dht.put(routingKey.toBuffer(), value, callback) | ||
} | ||
|
||
/** | ||
* Get a value from the local datastore indexed by the received key properly encoded. | ||
* @param {Buffer} key identifier of the value to be obtained. | ||
* @param {function(Error, Buffer)} callback | ||
* @returns {void} | ||
*/ | ||
get (key, callback) { | ||
// encode key properly - base32(/ipns/{cid}) TODO: remove this | ||
// const routingKey = new Key('/' + encodeBase32(key), false) | ||
|
||
this._dht.get(key, callback) | ||
// this._dht.get(routingKey.toBuffer(), callback) | ||
} | ||
} | ||
|
||
exports = module.exports = DhtDatastore |
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
Oops, something went wrong.