npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hoprnet/hopr-server

v1.45.0-alpha.0

Published

gRPC Server wrapper around HOPR Node

Downloads

8

Readme

Table of Contents

Overview

HOPR Server functions as a wrapper for a HOPR Node. Upon start, it will automatically spin a HOPR Node listening to port 9091 and create a gRPC-ready interface listening to port 50051 which automatically connects to the HOPR Network using the BOOTSTRAP_SERVERS defined.

To interact with HOPR Server, you need to use HOPR Protos, the Protobuf implementation of the HOPR Protocol which exposes its API via gRPC. HOPR Protos can be installed and used via nom by installing the distribution package.

Technologies

Getting Started

To get a local copy up and running follow these simple steps. In case you just want to have a runnable version of HOPR Server, you can use our Docker Image to quickly start the server.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

Installation

  1. Clone the repo
git clone https://github.com/hoprnet/hopr-server.git
  1. Install NPM packages
yarn

Docker Image

Pull latest version

docker pull gcr.io/hoprassociation/hopr-server

Run latest version

docker run -p 50051:50051 -p 9091:9091 -it gcr.io/hoprassociation/hopr-server

Run latest version w/specific BOOTSTRAP_SERVERS

docker run \
  -p 50051:50051 -p 9091:9091 \
  -e BOOTSTRAP_SERVERS=/ip4/34.65.75.45/tcp/9091/p2p/16Uiu2HAm2cjqsDMmprtN2QKaq3LJrq3YK7vtdbQQFsxGrhLRoYsy,/ip4/34.65.177.154/tcp/9091/p2p/16Uiu2HAm9C4oJPeRkdXnYxtXzFpDqpcCbWLsgNW4irrCLZTJ7cBd \
  -it gcr.io/hoprassociation/hopr-server

Usage

Upon installing, you can run yarn start to start the server which will use ts-node. Once you see :: HOPR Core Node Started ::, it means that the server has successfully connected to the HOPR Network using the defined BOOTSTRAP_SERVERS and is ready to accept requests.

In case you are looking to distribute the application, you can precompile it using yarn build, which will compile the nest.js TypeScript files and create a dist folder, which can then be used by node directly.

Commands

  1. yarn start - Starts HOPR Server in dev mode.
  2. yarn build - Builds HOPR Server for production.

For more information about the HOPR Network, please refer to the Documentation

Environment Variables

The following environment variables can be stored and used in an .env file located at the root of the project.

| Name | Description | Type | Example | | :---------------- | :----------------------------------------------------------- | :--------------- | :----------------------------------------------------------- | | SERVER_HOST | server HOST url | string | 0.0.0.0:50051 | | DEBUG_MODE | passed to hopr-core: run in debug mode | boolean | TRUE | | ID | passed to hopr-core: demo account ID | integer | 1 | | BOOTSTRAP_NODE | passed to hopr-core: TRUE if node is a boostrap node | boolean | FALSE | | CORE_HOST | passed to hopr-core: hopr-core HOST url | string | 0.0.0.0:9091 | | BOOTSTRAP_SERVERS | passed to hopr-core: a list of bootstap server to connect to | array of strings | src | | PROVIDER | passed to hopr-core: blockchain endpoint | string | wss://kovan.infura.io/ws/v3/f7240372c1b442a6885ce9bb825ebc36 |

Roadmap

See the issues for a list of proposed features (and known issues).

Additional Information

Query the server using BloomRPC (Recommended)

  1. Download and install BloomRPC.
  2. Download the .proto files that are used by our server.
  3. Import .proto files by clicking on the top-left + icon and navigating to previously downloaded files.
  4. Set the server url in the input at top-center to 127.0.0.1:50051

Quering

  1. Select on of the unary methods from the left panel, for example: version.proto -> version.Version -> GetVersion
  2. Click "play" (▶️), you should get a response of something like:
{
  "components_version": {
    "0": "@hoprnet/hopr-core,0.6.21",
    "1": "@hoprnet/hopr-core-connector-interface,1.3.2-35127fb",
    "2": "@hoprnet/hopr-core-ethereum,0.0.12-refactor.473415f",
    "3": "@hoprnet/hopr-utils,0.1.7-c598e77",
    "4": "@hoprnet/hopr-core-connector-interface,1.3.2-35127fb"
  },
  "version": "0.0.1"
}

Sending & Listening to messages

In this example, you will need to run two servers (server A and server B), one for sending a message and another for listening. Server B needs to be setup in a different directory from server A, as a HOPR Node creates a db directory which can not be shared between different instances.

  1. Start server A: yarn start
  2. Start server B: SERVER_HOST=0.0.0.0:50052 CORE_HOST=0.0.0.0:9092 yarn start
  3. Call GetStatus for both servers using BloomRPC, take note of their ids
  4. Call Listen on server B, peer_id is optional and can be removed, example input: {}
  5. Call Send on server A, example input can be:
{
  "peer_id": "<server B peer ID>",
  "payload": [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
}
  1. Server B should have received the message as a payload.

Querying the server using gCURL

  1. Install gCURL using npm install -g gcurl or yarn global add curl.
  2. Start the server yarn start
  3. Wait until terminal displays :: HOPR Core Node Started ::
  4. Call getStatus using gcurl -f ./node_modules/@hoprnet/hopr-protos/protos/status.proto --host 127.0.0.1:50051 --input '{}' --short status:Status:getStatus
  5. First getStatus call might take a minute to respond, you should receive a minified json response like:
{
  "id": "16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj",
  "multi_addresses": [
    "/ip4/93.109.190.135/tcp/9091/p2p/16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj",
    "/ip4/192.168.178.33/tcp/9091/p2p/16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj",
    "/ip4/172.17.2.177/tcp/9091/p2p/16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj",
    "/ip4/127.0.0.1/tcp/9091/p2p/16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj"
  ],
  "connected_nodes": 11,
  "cpu_usage": 0
}

Considerations

  • BloomRPC will sometimes insert default input data when calling certain methods, for example with Send it will insert:
{
  "peer_id": "316a50f5-4801-4065-bb73-5c602d594ccf",
  "payload": {
    "type": "Buffer",
    "data": [72, 101, 108, 108, 111]
  }
}

which is incompatible with our server, the right input is:

{
  "peer_id": "16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj",
  "payload": [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
}
  • Before calling Send you should call GetStatus, as the HOPR node might need to “discover” the other node from the network before it is able to send a message. Avoiding to do so might result in a Timeout error.

Links

Contributors

This project has been possible thanks to the support of the following individuals:

Contact

  • Twitter - https://twitter.com/hoprnet
  • Telegram - https://t.me/hoprnet
  • Medium - https://medium.com/hoprnet
  • Reddit - https://www.reddit.com/r/HOPR/
  • Email - [email protected]
  • Discord - https://discord.gg/5FWSfq7
  • Youtube - https://www.youtube.com/channel/UC2DzUtC90LXdW7TfT3igasA