tradle / multi-hyperbee

A LevelUP compatible leaderless multi-master database with eventual consistency, using hyperbee + CRDT + HLC. Similarly CockroachDB achieves replication on top of RocksDB, but here it is a pure P2P **streaming** database, with zero central management. LevelDB compatibility allows to use Dynalite on top to achieve DynamoDB compatibility with sophisticated auto-updated secondary indexes, and fairly complex queries. Work on Dynalite is almost completed to remove HTTP server, to make this combination perfect for serverless.
36 stars 5 forks source link

Issue in executing `example.js` #12

Closed raphael10-collab closed 2 years ago

raphael10-collab commented 2 years ago

I tried to run theexample: https://github.com/tradle/multi-hyperbee/tree/master/examples#to-run-this-example

(base) raphy@pc:~/hypercore/multi-hyperbee$ node examples/example.js -s pc_01
pc_01 diff key: c7c6136054bf70a09df8e8a2a3975aec7046df81c819b904c213f2f3f0995882
(base) raphy@pc:~/hypercore/multi-hyperbee$ 

(base) raphy@pc:~/hypercore/multi-hyperbee$ node examples/example.js -s pc_02
pc_02 diff key: 9cb2ad634fd4085b246be102811c72dc46af6d8f73473eb0f3ab9f0931e9b87d
(base) raphy@pc:~/hypercore/multi-hyperbee$ 

But I get this error:

(base) raphy@pc:~/hypercore/multi-hyperbee$ node examples/example.js -s [pc_01, pc_02] -k [c7c6136054bf70a09df8e8a2a3975aec7046df81c819b904c213f2f3f0995882, 9cb2ad634fd4085b246be102811c72dc46af6d8f73473eb0f3ab9f0931e9b87d]
[pc_01, diff key: 33eb800775fc50dd7d152da924ac433ccaba2d50599107d3e7724f74e18ccbe8
(node:50908) UnhandledPromiseRejectionWarning: Error: key
    at Object.exports.discoveryKey (/home/raphy/hypercore/multi-hyperbee/node_modules/hypercore-crypto/index.js:170:10)
    at new Feed (/home/raphy/hypercore/multi-hyperbee/node_modules/hypercore/index.js:81:42)
    at Feed (/home/raphy/hypercore/multi-hyperbee/node_modules/hypercore/index.js:54:39)
    at MultiHyperbee._addPeer (/home/raphy/hypercore/multi-hyperbee/index.js:279:20)
    at MultiHyperbee.addPeer (/home/raphy/hypercore/multi-hyperbee/index.js:154:23)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async start (/home/raphy/hypercore/multi-hyperbee/examples/example.js:52:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:50908) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:50908) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(base) raphy@pc:~/hypercore/multi-hyperbee$ 

(base) raphy@pc:~/hypercore/multi-hyperbee$ node examples/example.js -s [pc_01, pc_02] -k [c7c6136054bf70a09df8e8a2a3975aec7046df81c819b904c213f2f3f0995882]
[pc_01, diff key: 33eb800775fc50dd7d152da924ac433ccaba2d50599107d3e7724f74e18ccbe8
(node:54699) UnhandledPromiseRejectionWarning: Error: key
    at Object.exports.discoveryKey (/home/raphy/hypercore/multi-hyperbee/node_modules/hypercore-crypto/index.js:170:10)
    at new Feed (/home/raphy/hypercore/multi-hyperbee/node_modules/hypercore/index.js:81:42)
    at Feed (/home/raphy/hypercore/multi-hyperbee/node_modules/hypercore/index.js:54:39)
    at MultiHyperbee._addPeer (/home/raphy/hypercore/multi-hyperbee/index.js:279:20)
    at MultiHyperbee.addPeer (/home/raphy/hypercore/multi-hyperbee/index.js:154:23)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async start (/home/raphy/hypercore/multi-hyperbee/examples/example.js:52:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:54699) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:54699) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

(base) raphy@pc:~/hypercore/multi-hyperbee$ node examples/example.js -s [pc_01, pc_02] -k [9cb2ad634fd4085b246be102811c72dc46af6d8f73473eb0f3ab9f0931e9b87d]
[pc_01, diff key: 33eb800775fc50dd7d152da924ac433ccaba2d50599107d3e7724f74e18ccbe8
(node:56069) UnhandledPromiseRejectionWarning: Error: key
    at Object.exports.discoveryKey (/home/raphy/hypercore/multi-hyperbee/node_modules/hypercore-crypto/index.js:170:10)
    at new Feed (/home/raphy/hypercore/multi-hyperbee/node_modules/hypercore/index.js:81:42)
    at Feed (/home/raphy/hypercore/multi-hyperbee/node_modules/hypercore/index.js:54:39)
    at MultiHyperbee._addPeer (/home/raphy/hypercore/multi-hyperbee/index.js:279:20)
    at MultiHyperbee.addPeer (/home/raphy/hypercore/multi-hyperbee/index.js:154:23)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async start (/home/raphy/hypercore/multi-hyperbee/examples/example.js:52:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:56069) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:56069) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(base) raphy@pc:~/hypercore/multi-hyperbee$ 

What am I missing or / and doing wrongly?

bobwen-dev commented 2 years ago

Try removing the parenthesis and spaces in [pc_01, pc_02] and [9cb2ad634fd4085b246be102811c72dc46af6d8f73473eb0f3ab9f0931e9b87d]

raphael10-collab commented 2 years ago
(base) raphy@pc:~/hypercore/multi-hyperbee$ node examples/example.js -s pc_01
pc_01 diff key: 39bc566040817500b135889b7f0dede9f108e8b6dd10e065462fe92b28c0b751

(base) raphy@pc:~/hypercore/multi-hyperbee$ node examples/example.js -s pc_02
pc_02 diff key: 49b0a25c4538b9d2f6fc9092743bc9ea6da0b0248325057a855b3562935a864a

(base) raphy@pc:~/hypercore/multi-hyperbee$ node examples/example.js  -s pc_01,pc_02 -k 39bc566040817500b135889b7f0dede9f108e8b6dd10e065462fe92b28c0b751,49b0a25c4538b9d2f6fc9092743bc9ea6da0b0248325057a855b3562935a864a
pc_01,pc_02 diff key: fa859781bfa0cdfb3e1a3ece30dad14a586a138994ca8472467b92d3e1bed3b1
Please enter some data
trial_data
Hello World!
It's Saturday!

(base) raphy@pc:~/hypercore/multi-hyperbee$ ls -lah
total 184K
drwxrwxr-x  15 raphy raphy 4,0K set 18 12:07 .
drwxrwxr-x  11 raphy raphy 4,0K set 16 15:15 ..
-rw-rw-r--   1 raphy raphy  757 set 13 20:00 clock.js
drwxrwxr-x   2 raphy raphy 4,0K set 13 20:00 docs
drwxrwxr-x   4 raphy raphy 4,0K set 18 11:56 examples
drwxrwxr-x   8 raphy raphy 4,0K set 13 20:00 .git
-rw-rw-r--   1 raphy raphy   24 set 13 20:00 .gitignore
-rw-rw-r--   1 raphy raphy  11K set 13 20:00 index.js
-rw-rw-r--   1 raphy raphy  13K set 13 20:00 mergeHandler.js
drwxrwxr-x 179 raphy raphy 4,0K set 13 20:04 node_modules
-rw-rw-r--   1 raphy raphy 1,1K set 13 20:00 package.json
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:05 pc_01
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:26 pc_01_diff
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:26 pc_01,pc_02
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:07 pc_01,pc_02_diff
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:07 pc_01,pc_02_peer_1
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:07 pc_01,pc_02_peer_2
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:05 pc_02
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:05 pc_02_diff
-rw-rw-r--   1 raphy raphy 9,7K set 13 20:00 README.md
drwxrwxr-x   2 raphy raphy 4,0K set 13 20:00 test
-rw-rw-r--   1 raphy raphy 5,6K set 13 20:00 timestamp.js
-rw-rw-r--   1 raphy raphy  62K set 13 20:04 yarn.lock
(base) raphy@pc:~/hypercore/multi-hyperbee$ 

(base) raphy@pc:~/hypercore/multi-hyperbee/pc_01,pc_02$ ls -lah
total 32K
drwxrwxr-x  2 raphy raphy 4,0K set 18 12:07 .
drwxrwxr-x 15 raphy raphy 4,0K set 18 12:07 ..
-rw-rw-r--  1 raphy raphy 3,6K set 18 12:07 bitfield
-rw-rw-r--  1 raphy raphy  894 set 18 12:07 data
-rw-rw-r--  1 raphy raphy   32 set 18 12:07 key
-rw-rw-r--  1 raphy raphy   64 set 18 12:07 secret_key
-rw-rw-r--  1 raphy raphy  480 set 18 12:07 signatures
-rw-rw-r--  1 raphy raphy  552 set 18 12:07 tree

(base) raphy@pc:~/hypercore/multi-hyperbee/pc_01,pc_02$ cat data 

hyperbee    
__peers

__peers�D["39bc566040817500b135889b7f0dede9f108e8b6dd10e065462fe92b28c0b751"]

__peers��["39bc566040817500b135889b7f0dede9f108e8b6dd10e065462fe92b28c0b751","49b0a25c4538b9d2f6fc9092743bc9ea6da0b0248325057a855b3562935a864a"]

pc_01,pc_02_123��{"firstName":"J","lastName":"S","someField":0.5815352464436727,"friends":["Claire","Martha","Jake","Sean"],"_objectId":"pc_01,pc_02_123","_timestamp":"2021-09-18T10:07:06.732Z-0000"}

pc_01,pc_02_trialdata�f{"text":"trial_data","_objectId":"pc_01,pc_02_trialdata","_timestamp":"2021-09-18T10:07:19.745Z-0000"}

pc_01,pc_02_HelloWorld�i{"text":"Hello World!","_objectId":"pc_01,pc_02_HelloWorld","_timestamp":"2021-09-18T10:07:32.769Z-0000"}

pc_01,pc_02_ItsSaturday�l{"text":"It's Saturday!","_objectId":"pc_01,pc_02_ItsSaturday","_timestamp":"2021-09-18T10:07:48.975Z-0000"}

It seems working now.

It's not clear to me the folders structure:

drwxrwxr-x   2 raphy raphy 4,0K set 18 12:05 pc_01
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:26 pc_01_diff
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:29 pc_01,pc_02
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:07 pc_01,pc_02_diff
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:07 pc_01,pc_02_peer_1
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:07 pc_01,pc_02_peer_2
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:05 pc_02
drwxrwxr-x   2 raphy raphy 4,0K set 18 12:05 pc_02_diff

For example. Why here there is no data file?

(base) raphy@pc:~/hypercore/multi-hyperbee/pc_01,pc_02_peer_1$ ls -lah
total 24K
drwxrwxr-x  2 raphy raphy 4,0K set 18 12:07 .
drwxrwxr-x 15 raphy raphy 4,0K set 18 12:07 ..
-rw-rw-r--  1 raphy raphy   32 set 18 12:07 bitfield
-rw-rw-r--  1 raphy raphy   32 set 18 12:07 key
-rw-rw-r--  1 raphy raphy   32 set 18 12:07 signatures
-rw-rw-r--  1 raphy raphy   32 set 18 12:07 tree

(base) raphy@pc:~/hypercore/multi-hyperbee/pc_01,pc_02_diff$ cat data

hyperbee
multi-hyperbee-diff

-pc_01,pc_02_123/2021-09-18T10:07:06.732Z-0000��{"_timestamp":"2021-09-18T10:07:06.732Z-0000","obj":{"_objectId":"pc_01,pc_02_123"},"list":{"add":{"firstName":"J","lastName":"S","someField":0.5815352464436727,"friends":["Claire","Martha","Jake","Sean"]}}}

3pc_01,pc_02_trialdata/2021-09-18T10:07:19.745Z-0000�{"_timestamp":"2021-09-18T10:07:19.745Z-0000","obj":{"_objectId":"pc_01,pc_02_trialdata"},"list":{"add":{"text":"trial_data"}}}

4pc_01,pc_02_HelloWorld/2021-09-18T10:07:32.769Z-0000��{"_timestamp":"2021-09-18T10:07:32.769Z-0000","obj":{"_objectId":"pc_01,pc_02_HelloWorld"},"list":{"add":{"text":"Hello World!"}}}

5pc_01,pc_02_ItsSaturday/2021-09-18T10:07:48.975Z-0000��{"_timestamp":"2021-09-18T10:07:48.975Z-0000","obj":{"_objectId":"pc_01,pc_02_ItsSaturday"},"list":{"add":{"text":"It's Saturday!"}}}

:pc_01,pc_02_TomorrowisSunday/2021-09-18T10:37:22.038Z-0000��{"_timestamp":"2021-09-18T10:37:22.038Z-0000","obj":{"_objectId":"pc_01,pc_02_TomorrowisSunday"},"list":{"add":{"text":"Tomorrow is Sunday"}}}(base) 

And where does this line come from?

    -pc_01,pc_02_123/2021-09-18T10:07:06.732Z-0000��{"_timestamp":"2021-09-18T10:07:06.732Z-0000","obj":{"_objectId":"pc_01,pc_02_123"},"list":{"add":{"firstName":"J","lastName":"S","someField":0.5815352464436727,"friends":["Claire","Martha","Jake","Sean"]}}}