Giter Site home page Giter Site logo

consensource-api's Introduction

ConsenSource rest api Build Status Coverage Status

The ConsenSource rest api is a Rust server that has endpoints for fetching data from Postgres, and posting transactions/batches to the Processor.

How the rest api works

Batches

Batches submitted from a client (web app, cli, etc) are sent to the /batches endpoint as a serialized payload. This endpoint deserializes the payload and creates a protocol buffer. The ConsenSource proto formats can be found in the common repo.

The protobuf is sent to the Transaction Processor, and the REST API responds with a url /batch_statuses?<batch_ids>. This endpoint monitors Sawtooth state and returns a JSON payload indicating the status of a batch, and if has been committed to a block.

Server-Sent Events (SSE)

A SSE server is created along with the REST API in order to send new data to web ui. Details on SSE can be found on Mozilla's docs. The Rust library we are using for SSE can be found here.

Development

The ConsenSource REST API is written using the Rocket web framework. It requires nightly, though is very close to being stabilized.

Switch over to nightly

rustup toolchain install nightly rustup default nightly 

Install the nightly linter

rustup component add rustfmt --toolchain nightly 

Format (linting)

cargo +nightly fmt -- --check 

Test

Most of the Rest API tests are integration tests. To startup a Postgres and Rest API instance and run these tests with code coverage metrics:

cd test
docker-compose up

Build

cargo build 

Run

You'll need to run ConsenSource from the compose repo. The compose repo is a git submodules repo that references all the components that make up ConsenSource.

NOTE: The consensource-compose repo is only for pulling changes and running the project as a whole, it is not for development.

consensource-api's People

Contributors

adeebahmed avatar patrick-erichsen avatar

Watchers

 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.