diff --git a/README.md b/README.md index 23ec781..66b20dc 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,7 @@ Send one of the following messages to the protocol in order to communicate with #### Adding a DB for replication ``` -type: PIN_ADD +type: 1 ("ADD") id: The id of the requester signature: One or more database addresses signed by the requester addresses: One or more database addresses to add to the storage @@ -231,7 +231,7 @@ If successful, an OK response will be sent. If it fails, an error will be return #### Removing a DB for replication ``` -type: PIN_REMOVE +type: 2 ("REMOVE") id: The id of the requester signature: One or more database addresses signed by the requester addresses: One or more database addresses to remove from the storage diff --git a/src/lib/handle-request.js b/src/lib/handle-request.js index ffc04bc..22710c5 100644 --- a/src/lib/handle-request.js +++ b/src/lib/handle-request.js @@ -32,12 +32,12 @@ export const handleRequest = (orbiter) => source => { } switch (type) { - case Requests.PIN_ADD: { + case Requests.ADD: { await handleAddRequest({ orbitdb, databases, id, addresses }) response = ResponseMessage(Responses.OK) break } - case Requests.PIN_REMOVE: { + case Requests.REMOVE: { await handleRemoveRequest({ orbitdb, databases, id, addresses }) response = ResponseMessage(Responses.OK) break diff --git a/src/lib/lander.js b/src/lib/lander.js index 0dd42a0..c569d68 100644 --- a/src/lib/lander.js +++ b/src/lib/lander.js @@ -21,14 +21,14 @@ export default async ({ orbitdb, orbiterAddressOrId }) => { } const add = async (addresses) => { - const addDBs = () => [request(Requests.PIN_ADD, toArray(addresses))] + const addDBs = () => [request(Requests.ADD, toArray(addresses))] const stream = await orbitdb.ipfs.libp2p.dialProtocol(orbiterAddressOrId, voyagerProtocol, { runOnLimitedConnection: true }) const added = await pipe(addDBs, stream, parseResponse) return added } const remove = async (addresses) => { - const removeDBs = () => [request(Requests.PIN_REMOVE, toArray(addresses))] + const removeDBs = () => [request(Requests.REMOVE, toArray(addresses))] const stream = await orbitdb.ipfs.libp2p.dialProtocol(orbiterAddressOrId, voyagerProtocol, { runOnLimitedConnection: true }) const removed = await pipe(removeDBs, stream, parseResponse) return removed diff --git a/src/lib/messages/index.js b/src/lib/messages/index.js index fbeac4d..bb92fb6 100644 --- a/src/lib/messages/index.js +++ b/src/lib/messages/index.js @@ -2,8 +2,8 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' export const Requests = Object.freeze({ - PIN_ADD: 1, - PIN_REMOVE: 2 + ADD: 1, + REMOVE: 2 }) export const Responses = Object.freeze({ diff --git a/test/messages.test.js b/test/messages.test.js index 9c838b3..209208b 100644 --- a/test/messages.test.js +++ b/test/messages.test.js @@ -17,7 +17,7 @@ describe('Messages', function () { const addDBs = ({ type, signer } = {}) => source => { return (async function * () { const addresses = [db.address] - const message = await RequestMessage(type || Requests.PIN_ADD, addresses, lander.orbitdb.identity, signer) + const message = await RequestMessage(type || Requests.ADD, addresses, lander.orbitdb.identity, signer) yield message })() }