Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
5 contributors

Users who have contributed to this file

@ivan-ochc @DarkEld3r @boguslavsky @MartaDubno @aleksuss
146 lines (89 sloc) 4.77 KB

Timestamping: Example Service

This project demonstrates how to create simple timestamping service using Exonum blockchain.

Timestamping demo

Getting started

Be sure you installed necessary packages:

Install and run

Using docker

Simply run the following command to start the timestamping service on 4 nodes on the local machine:

docker run -p 8000-8008:8000-8008 exonumhub/exonum-timestamping:demo

Ready! Find demo at http://127.0.0.1:8008.

Docker will automatically pull image from the repository and run 4 nodes with public endpoints at 127.0.0.1:8000, ..., 127.0.0.1:8003 and private ones at 127.0.0.1:8004, ..., 127.0.0.1:8007.

To stop docker container, use docker stop <container id> command.

Manually

Getting started

Be sure you installed necessary packages:

Install and run

Below you will find a step-by-step guide to start the service on 4 nodes on the local machine.

Clone the project and install Rust dependencies:

git clone https://github.com/exonum/exonum

cd exonum/examples/timestamping/backend

cargo install --path .

Generate blockchain configuration:

mkdir example

exonum-timestamping generate-template example/common.toml --validators-count 4

Generate templates of nodes configurations:

exonum-timestamping generate-config example/common.toml  example/pub_1.toml example/sec_1.toml --peer-address 127.0.0.1:6331 -c example/consensus_1.toml -s example/service_1.toml -n

exonum-timestamping generate-config example/common.toml  example/pub_2.toml example/sec_2.toml --peer-address 127.0.0.1:6332 -c example/consensus_2.toml -s example/service_2.toml -n

exonum-timestamping generate-config example/common.toml  example/pub_3.toml example/sec_3.toml --peer-address 127.0.0.1:6333 -c example/consensus_3.toml -s example/service_3.toml -n

exonum-timestamping generate-config example/common.toml  example/pub_4.toml example/sec_4.toml --peer-address 127.0.0.1:6334 -c example/consensus_4.toml -s example/service_4.toml -n

Note that in case of copying files with consensus and service keys to the other machines, you must change the access permissions of these files for every machine. For example:

sudo chmod 600 consensus_1.toml
sudo chmod 600 service_1.toml

Finalize generation of nodes configurations:

exonum-timestamping finalize --public-api-address 0.0.0.0:8200 --private-api-address 0.0.0.0:8091 example/sec_1.toml example/node_1_cfg.toml --public-configs example/pub_1.toml example/pub_2.toml example/pub_3.toml example/pub_4.toml

exonum-timestamping finalize --public-api-address 0.0.0.0:8201 --private-api-address 0.0.0.0:8092 example/sec_2.toml example/node_2_cfg.toml --public-configs example/pub_1.toml example/pub_2.toml example/pub_3.toml example/pub_4.toml

exonum-timestamping finalize --public-api-address 0.0.0.0:8202 --private-api-address 0.0.0.0:8093 example/sec_3.toml example/node_3_cfg.toml --public-configs example/pub_1.toml example/pub_2.toml example/pub_3.toml example/pub_4.toml

exonum-timestamping finalize --public-api-address 0.0.0.0:8203 --private-api-address 0.0.0.0:8094 example/sec_4.toml example/node_4_cfg.toml --public-configs example/pub_1.toml example/pub_2.toml example/pub_3.toml example/pub_4.toml

Run nodes:

exonum-timestamping run --node-config example/node_1_cfg.toml --db-path example/db1 --public-api-address 0.0.0.0:8200 --consensus-key-pass pass --service-key-pass pass

exonum-timestamping run --node-config example/node_2_cfg.toml --db-path example/db2 --public-api-address 0.0.0.0:8201 --consensus-key-pass pass --service-key-pass pass

exonum-timestamping run --node-config example/node_3_cfg.toml --db-path example/db3 --public-api-address 0.0.0.0:8202 --consensus-key-pass pass --service-key-pass pass

exonum-timestamping run --node-config example/node_4_cfg.toml --db-path example/db4 --public-api-address 0.0.0.0:8203 --consensus-key-pass pass --service-key-pass pass

Install frontend dependencies:

cd ../frontend

npm install

Build sources:

npm run build

Run the application:

npm start -- --port=2268 --api-root=http://127.0.0.1:8200

--port is a port for Node.JS app.

--api-root is a root URL of public API address of one of nodes.

Ready! Find demo at http://127.0.0.1:2268.

License

Timestamping demo is licensed under the Apache License (Version 2.0). See LICENSE for details.

You can’t perform that action at this time.