Skip to content

hikkymouse1007/nostr_protocol

Repository files navigation

nostr_protocol

week1

  • result result

  • What are some of the challenges you faced while working on Phase 1?

    • I had previously worked with web sockets, so I had a basic understanding of how they work. However, I had no knowledge of the Nostr Protocol, so I had no idea how to implement the code. However, during my research, I came across a JavaScript tool called nostro-tools, which allowed me to connect to the server based on this tool. Through implementing with this tool, I was able to gain a general understanding of how to connect to the relay server and publish events using this protocol.
  • What kind of failures do you expect to a project such as DISTRISE to encounter?

    • The server architecture can not handle the increased load from multiple connections, as with traditional WebSocket implementations.
    • In the event of a system failure, data restoration can not be performed correctly.
    • Ensuring the security and (if necessary, anonymity) of transmitted data.

Week2

Setup

  • Run DynamoDB database server
docker compose up
  • Initialize the database to create table
node createDB.js
  • Start running relay server
node relayServer.js
  • Send event to relay server
node sampleNostr.js
Stored data in DynamoDB

Challenges faced:

  • It was challenging to determine the authentication method for the messages received on the server side and decide how to store the messages on the server using a specific type of database.
  • I was unsure about the appropriate handling of REQ and CLOSE data, which made it difficult to successfully implement them.

RabbitMQ

RABBITMQ_ENDPOINT='amqp://myuser:mypassword@localhost:5672'

week5

Architecture

You can find my websocket server-side repo here: https://github.com/hikkymouse1007/ nostr_server

スクリーンショット 2023-06-04 19 23 38

Usage

  • Run the command to start up your docker compose(including rabbitMQ and dynamoDB for local)
docker compose up
  • Open another terminal window and run aggregator.js
node aggregator/aggregator.js

You can add as many available websocket servers as you want to the array const RELAYS:

const RELAYS = ['wss://relay.nekolicio.us/', 'wss://floating-fortress-37708.herokuapp.com'];

and you can see the log below: スクリーンショット 2023-06-04 19 23 38

  • Open another window and run eventConsumer.js to consume enqueued event queues and store them to your local DynamoDB database
node aggregator/services/eventConsumer.js

スクリーンショット 2023-06-04 19 17 18

You can see the stored data on your localhost:8001: スクリーンショット 2023-06-04 19 23 38

  • You can see the data by running dbWatcher.js which fetches latest event created within 30 seconds before dbWatcher runs every 10 seconds from your local DynamoDB
node dbWatcher

スクリーンショット 2023-06-04 19 23 38

However, this code has some problems:

  • You have to scan all data in the table for the aggregator every time dbWatcher runs due to the feature of scanning of DynamoDB
  • You can not see every single data precisely depending on the timing the code runs

But this is for not fetching duplicated data more than once as possible.

Acknowledgment

I would like to extend my heartfelt thanks to Kyle for his exceptional contribution in the development of the nostro-server implementation using JavaScript. I found immense value in referring to Kyle's repository (https://github.com/kylemocode/nostr-distributed-system-exercise/tree/main/nostr-aggregator) during my work.

His code provided valuable insights into utilizing the nostr-tools and amqplib libraries, enabling me to better understand how to establish communication with the nostro-server and implement queueing functionalities. I am truly grateful for his invaluable assistance.

I would like to take this opportunity to express my sincere appreciation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published