GithubHelp home page GithubHelp logo

learner25 / core Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thenewboston-developers/core

0.0 0.0 0.0 473 KB

Core messaging server.

License: MIT License

Shell 5.45% Python 91.44% Makefile 2.01% Dockerfile 1.10%

core's Introduction

Project setup

For project setup see OS-dependent installation instructions:

Example usage

Request:

{
  "id": "dc348eac-fc89-4b4e-96de-4a988e0b94e1",
  "amount": 5,
  "payload": {
    "message": "Hey"
  },
  "recipient": "995bd2a4db610062f404510617e83126fa37e2836805975f334108b55523634c",
  "sender": "eb01f474a637e402b44407f3c1044a0c4b59261515d50be9abd4ee34fcb9075b",
  "transaction_fee": 1,
  "signature": "4b86d923cfc7603f39e1d0c36afcec2e454c624b1dc4dd03bf6764e4662162644d0a78c864d16bb7e4608a76db6df0e842a550c52d4811f81d8049f273da8a01"
}

Response:

{
  "id": "dc348eac-fc89-4b4e-96de-4a988e0b94e1",
  "sender": "eb01f474a637e402b44407f3c1044a0c4b59261515d50be9abd4ee34fcb9075b",
  "signature": "4b86d923cfc7603f39e1d0c36afcec2e454c624b1dc4dd03bf6764e4662162644d0a78c864d16bb7e4608a76db6df0e842a550c52d4811f81d8049f273da8a01",
  "recipient": "995bd2a4db610062f404510617e83126fa37e2836805975f334108b55523634c",
  "amount": 5,
  "transaction_fee": 1,
  "payload": {
    "message": "Hey"
  }
}

wss://thenewboston.network/ws/accounts/{ACCOUNT_NUMBER}

Connect and authenticate to receive any incoming messages sent to the ACCOUNT_NUMBER.

Requests

Authentication:

{
  "method": "authenticate",
  "token": "6fac7f7e2b90173bfc6ef8ee34f9c92438b5eb8f579ef8d84464b820bbfecfc1$2022-08-11T01:28:47.811436+00:00$14b38d51678062770fd3135fa94925638331160102e7cfb50ab9152ee00a56b03445ea8f36e8d502faf6a3f8413920ddacbd4c763c93108fafff2bb5071ba40f",
  "correlation_id": "any-random-string-to-identify-response"
}

token format: {account_number}${iso_formatted_datetime}${signature}

Set peers:

{
  "method": "set_peers",
  "peers": ["eb01f474a637e402b44407f3c1044a0c4b59261515d50be9abd4ee34fcb9075b", "995bd2a4db610062f404510617e83126fa37e2836805975f334108b55523634c"],
  "correlation_id": "any-random-string-to-identify-response"
}

Get peers:

{
  "method": "get_peers",
  "correlation_id": "any-random-string-to-identify-response"
}

Responses

Authentication success:

{
  "return_value": true,
  "correlation_id": "any-random-string-to-identify-response"
}

Authentication failure:

{
  "return_value": false,
  "correlation_id": "any-random-string-to-identify-response"
}

Set peers:

{
  "return_value": None,
  "correlation_id": "any-random-string-to-identify-response"
}

Get peers:

{
  "return_value": {
    "eb01f474a637e402b44407f3c1044a0c4b59261515d50be9abd4ee34fcb9075b": {
      "is_online: False
    },
    "995bd2a4db610062f404510617e83126fa37e2836805975f334108b55523634c": {
      "is_online": True
    }
  },
  "correlation_id": "any-random-string-to-identify-response"
}

Create block message:

{
  "type": "create.block",
  "message": {
    "id": "dc348eac-fc89-4b4e-96de-4a988e0b94e1",
    "sender": "eb01f474a637e402b44407f3c1044a0c4b59261515d50be9abd4ee34fcb9075b",
    "recipient": "6fac7f7e2b90173bfc6ef8ee34f9c92438b5eb8f579ef8d84464b820bbfecfc1",
    "amount": 5,
    "transaction_fee": 1,
    "payload": {
      "message": "Hey"
    },
    "signature": "faddf38480b607861e90b656a367a39e5a09dff00082df3fdbdabcfb71c8677488d68a9b7a9bf963299e00fa8a6480c202b12a01c74bbb349ed929a36c8c860a"
  }
}

Update account message:

{
  "type": "update.account",
  "message": {
    "account_number": "6fac7f7e2b90173bfc6ef8ee34f9c92438b5eb8f579ef8d84464b820bbfecfc1",
    "balance": 35
  }
}

Peer is online message:

{
  "type": "track.online_status",
  "is_online": true,
  "account_number": "995bd2a4db610062f404510617e83126fa37e2836805975f334108b55523634c",
}

Peer is offline message:

{
  "type": "track.online_status",
  "is_online": false,
  "account_number": "eb01f474a637e402b44407f3c1044a0c4b59261515d50be9abd4ee34fcb9075b",
}

core's People

Contributors

dmugtasimov avatar buckyroberts avatar olegtropinin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.