diff --git a/packages/compliance-tests/CHANGELOG.md b/packages/compliance-tests/CHANGELOG.md index 304808840..24dbe7d41 100644 --- a/packages/compliance-tests/CHANGELOG.md +++ b/packages/compliance-tests/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.1.2](https://github.com/libp2p/js-libp2p-interfaces/compare/libp2p-interfaces-compliance-tests@1.1.1...libp2p-interfaces-compliance-tests@1.1.2) (2021-10-18) + +**Note:** Version bump only for package libp2p-interfaces-compliance-tests + + + + + ## [1.1.1](https://github.com/libp2p/js-libp2p-interfaces/compare/libp2p-interfaces-compliance-tests@1.1.0...libp2p-interfaces-compliance-tests@1.1.1) (2021-09-20) **Note:** Version bump only for package libp2p-interfaces-compliance-tests diff --git a/packages/compliance-tests/package.json b/packages/compliance-tests/package.json index 5a5dc28b3..7d244f722 100644 --- a/packages/compliance-tests/package.json +++ b/packages/compliance-tests/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-interfaces-compliance-tests", - "version": "1.1.1", + "version": "1.1.2", "description": "Compliance tests for JS Libp2p interfaces", "files": [ "src", @@ -43,7 +43,7 @@ "it-goodbye": "^3.0.0", "it-pair": "^1.0.0", "it-pipe": "^1.1.0", - "libp2p-interfaces": "^1.1.1", + "libp2p-interfaces": "^1.2.0", "multiaddr": "^10.0.0", "p-defer": "^3.0.0", "p-limit": "^3.1.0", diff --git a/packages/interfaces/CHANGELOG.md b/packages/interfaces/CHANGELOG.md index 00c852f97..d56eeb4be 100644 --- a/packages/interfaces/CHANGELOG.md +++ b/packages/interfaces/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.2.0](https://github.com/libp2p/js-interfaces/compare/libp2p-interfaces@1.1.1...libp2p-interfaces@1.2.0) (2021-10-18) + + +### Features + +* add ValueStore interface ([#108](https://github.com/libp2p/js-interfaces/issues/108)) ([09c6e10](https://github.com/libp2p/js-interfaces/commit/09c6e10353c1d8842a5522d28d5cd38ae47d892f)) + + + + + ## [1.1.1](https://github.com/libp2p/js-interfaces/compare/libp2p-interfaces@1.1.0...libp2p-interfaces@1.1.1) (2021-09-20) diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 3f25b199b..3a357e28a 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-interfaces", - "version": "1.1.1", + "version": "1.2.0", "description": "Interfaces for JS Libp2p", "leadMaintainer": "Jacob Heun ", "main": "src/index.js", diff --git a/packages/interfaces/src/value-store/README.md b/packages/interfaces/src/value-store/README.md new file mode 100644 index 000000000..5a9384a2b --- /dev/null +++ b/packages/interfaces/src/value-store/README.md @@ -0,0 +1,70 @@ +interface-value-store +===================== + +**WIP: This module is not yet implemented** + +> A test suite and interface you can use to implement a Value Store module for libp2p. + +A Value Store is a key/value storage interface that may be used to provide libp2p services such as Content Routing, service advertisment, etc. + +The primary goal of this module is to enable developers to pick and swap their Value Store module as they see fit for their libp2p installation, without having to go through shims or compatibility issues. This module and test suite were heavily inspired by abstract-blob-store and interface-stream-muxer. + +Publishing a test suite as a module lets multiple modules all ensure compatibility since they use the same test suite. + +# Modules that implement the interface + +- [JavaScript libp2p-kad-dht](https://github.com/libp2p/js-libp2p-kad-dht) +- [JavaScript libp2p-delegated-content-routing](https://github.com/libp2p/js-libp2p-delegated-content-routing) + - provided by the `DelegatedValueStore` class + +# How to use the battery of tests + +## Node.js + +TBD + +# API + +A valid (read: that follows this abstraction) Content Routing module must implement the following API. + +### put + +- `put(key, value, options)` + +Associate a value with the given key. + +**Parameters** +- `key`: `Uint8Array` - the key used to identify the value. +- `value`: `Uint8Array` - the value to associate with the key. +- `options`: `object | undefined` +- `options.timeout`: `number` - timeout in ms. + +Note that implementations may specify additional options, and must ignore unknown options. + +**Returns** + +A `Promise` that will resolve with no value on success, or fail with an `Error` if something goes wrong. + +### get + +- `get(key, options)` + +Fetch the value for the given key. + +**Parameters** +- `key`: `Uint8Array` - the key used to identify the value. +- `options`: `object | undefined` +- `options.timeout`: `number` - timeout in ms. + +Note that implementations may specify additional options, and must ignore unknown options. + +**Returns** + +A `Promise` that resolves with an object of the following shape on success: + +```js +{ + from: PeerId, + val: Uint8Array, +} +``` diff --git a/packages/interfaces/src/value-store/types.d.ts b/packages/interfaces/src/value-store/types.d.ts new file mode 100644 index 000000000..e3aa37aff --- /dev/null +++ b/packages/interfaces/src/value-store/types.d.ts @@ -0,0 +1,13 @@ +import type PeerId from 'peer-id' + +export interface GetValueResult { + from: PeerId, + val: Uint8Array, +} + +export interface ValueStore { + put (key: Uint8Array, value: Uint8Array, options?: Object): Promise + get (key: Uint8Array, options?: Object): Promise +} + +export default ValueStore