8000 GitHub - adeebahmed/consensource-api: API for sending batches to the process, and reading from pg · GitHub
[go: up one dir, main page]

Skip to content

About

API for sending batches to the process, and reading from pg

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

API for sending batches to the process, and reading from pg

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0