hoprnet / hopr-core

Main repository of HOPR - this is all you need to run a node on the HOPR network!
https://hoprnet.org
GNU General Public License v3.0
14 stars 5 forks source link

Write down hopr-server resource spec in protonbuf #117

Closed 0xjjpa closed 4 years ago

0xjjpa commented 4 years ago

Introduction

As we are moving to setting up a daemon-like process that is able to run hopr-core in the background and understand commands via a gRPC interface, we need to setup the common connector interface in protobuf compatible resources as to be used for hopr-server.

Task Description

Definition of Complete

The task is considered completed when all Stage 0 to 3 defined resources had been defined as protobuf resources.

Testing Criteria

Notes

Web Architecture MVP

Web Server MVP Architectural

node server.js --usesCoverTraffic=true --logLevel=4 ...

hopr-server
  |_ @hoprnet/hopr-core

server.ts
\__ import { default as HOPR } from '@hoprnet/hopr-core'
      const hoprNode = new HOPR({...})
      hoprNode.send(...)

Stage 0 - describe               GET   /status ({} => { ip, load, cpu_usage, connected_nodes })
Stage 0 - describe               GET   /version ({} => { version, components_version })
Stage 0 - quit                      POST /shutdown ({} => { timestamp })
Stage 0 - ping                     POST /ping ({peerId} => { pingReceipt:latency })
Stage 0 - .env                      POST /settings ({Settings:bootstrap_servers, is_using_cover_traffic})

Stage 1 - balance               GET   /balance/native ({} => { amount })
Stage 1 - balance               GET   /balance/hopr ({} => { amount })
Stage 1 - myAddress         GET   /address/native ({} => { amount })
Stage 1 - myAddress         GET   /address/hopr ({} => { amount })

Stage 2.a - listChannel      GET   /channels ({} => { open_channel[] })
Stage 2.a - openChannel  POST  /channels ({peerId} => channelTxReceipt:{channelId,...})
Stage 2.a - listChannel     GET    /channels/:channelId ({channelId} => { state, balance, ... })
Stage 2.a - closeChannel  POST  /channels/:channelId/close ({channelId} => channelTxReceipt)
Stage 2.b - crawl               POST  /crawl ({} => connected_nodes[])
Stage 2.b - listen*              POST /listen ({} => EventHandler) // e.g. on.message(..., fn)
Stage 2.b - send                 POST /send ({peerID, payload, [intermediatePeerIds[], timeout]} => txReceipt)

Stage 3 - transfer*            POST /transfer/native ({address, amount} => txReceipt)
Stage 3 - transfer*            POST /transfer/hopr ({address,amount} => txReceipt)

Recommended readings about gRPC

nionis commented 4 years ago

Implemented Stage 0 to Stage 2.a

0xjjpa commented 4 years ago

@nionis Let's create a README with this spec and close this issue.

0xjjpa commented 4 years ago

To be continued in https://github.com/hoprnet/hopr-core/issues/179, the proto initial work has already being laid down here. Closing.