Official Javascript implementation of AI Network Blockchain.
Tracker server is required by new peers who wish to join the AIN network. Each peer is sent the ipaddress of 2 other nodes in the network. These nodes then gossip information through the network of all transactions and blocks.
NOTE: Tracker Server must be started first before starting any blockchain node instances
- Clone this repository and install npm packages
git clone https://github.com/ainblockchain/ain-blockchain.git
cd ain-blockchain/tracker-server/
npm install
cd ..
- Run Tracker server
node tracker-server/index.js
- Deploy code (in common with Node server)
gcloud init
sh deploy_gcp.sh {dev|spring|summer} <YOUR_GCP_USER_NAME>
- Set up Ubuntu machine (if it's on a new VM)
sh setup_ubuntu.sh
- Copy files to a sharable folder & install npm packages
sh setup_tracker_gcp.sh
- Start tracker server job
cd ain-blockchain/
sh start_tracker_gcp.sh
GET http://<ip_address>:5000/
GET http://<ip_address>:5000/peer_nodes
Operates a single peer node instance of the AIN blockchain. A single blockchain node instance processes incoming transaction requests and maintains a local copy of the entire blockchain. The blockchain node first queries the tracker-server for ip addresses of other peers, and then syncs its local blockchain to the network consensus blockchain. If the blockchain specifies a "STAKE" argument on startup, it will then begin to take part in the forging/validating process for new blocks.
- Clone this repository and install npm packages
git clone https://github.com/ainblockchain/ain-blockchain.git
cd ain-blockchain/
npm install
- Run blockchain nodes
STAKE=250 ACCOUNT_INDEX=0 HOSTING_ENV=local DEBUG=false node client/index.js
STAKE=250 ACCOUNT_INDEX=1 HOSTING_ENV=local DEBUG=false node client/index.js
STAKE=250 ACCOUNT_INDEX=2 HOSTING_ENV=local DEBUG=false node client/index.js
STAKE=250 ACCOUNT_INDEX=3 HOSTING_ENV=local DEBUG=false node client/index.js
STAKE=250 ACCOUNT_INDEX=4 HOSTING_ENV=local DEBUG=false node client/index.js
Before starting node jobs, remove existing blockchain files and logs if necessary:
rm -rf blockchain/blockchains logger/logs
npm run test_unit
npm run test_smoke
npm run test_integration
- Deploy code (in common with Tracker server)
gcloud init
sh deploy_gcp.sh {dev|spring|summer} <YOUR_GCP_USER_NAME>
- Set up Ubuntu machine (if it's on a new VM)
sh setup_ubuntu.sh
- Copy files to a sharable folder & install npm packages
sh setup_node_gcp.sh
- Start Node server job
sh start_node_gcp.sh {dev|spring|summer} <SERVER_INDEX>
GET http://<ip_address>:8080/
GET http://<ip_address>:8080/blocks
GET http://<ip_address>:8080/blocks?from=1&to=100
GET http://<ip_address>:8080/tx_pool
GET http://<ip_address>:8080/tx_tracker
GET http://<ip_address>:8080/committed_nonce_tracker
GET http://<ip_address>:8080/pending_nonce_tracker
GET http://<ip_address>:8080/get_value?ref=/db/path/to/fetch
GET http://<ip_address>:8080/get_rule?ref=/db/path/to/fetch
GET http://<ip_address>:8080/get_function?ref=/db/path/to/fetch
GET http://<ip_address>:8080/get_owner?ref=/db/path/to/fetch
GET http://<ip_address>:8080/match_rule?ref=/db/path/to/match
GET http://<ip_address>:8080/match_function?ref=/db/path/to/match
GET http://<ip_address>:8080/match_owner?ref=/db/path/to/match
POST http://<ip_address>:8080/eval_rule with json_body {"ref": "/db/path/to/eval", "value": "some value", "address": "0xABCD...Z", "timestamp": "1234567890"}
POST http://<ip_address>:8080/eval_owner with json_body {"ref": "/db/path/to/eval", "permission": "write_rule", "address": "0xABCD...Z"}
POST http://<ip_address>:8080/get with json_body {"op_list": [{"type": "GET_VALUE", "ref": "/db/path/to/fetch"}, {"type": "GET_RULE", "ref": "/db/path/to/fetch2"}]}
POST http://<ip_address>:8080/set_value with json_body {"ref": "/db/path/to/set", "value": "some value"}
POST http://<ip_address>:8080/inc_value with json_body {"ref": "/db/path/to/increase", "value": 10}
POST http://<ip_address>:8080/dec_value with json_body {"ref": "/db/path/to/decrease", "value": 10}
POST http://<ip_address>:8080/set_rule with json_body {"ref": "/db/path/to/set", "value": "some rule config"}
POST http://<ip_address>:8080/set_function with json_body {"ref": "/db/path/to/set", "value": "some function config"}
POST http://<ip_address>:8080/set_owner with json_body {"ref": "/db/path/to/set", "value": "some owner config"}
POST http://<ip_address>:8080/set with json_body {"op_list": [{"type": "SET_VALUE", "ref": "/db/path/to/set", "value": "some value}, {"type": "SET_RULE", "ref": "/db/path/to/set2", "value": "some rule"}]}
POST http://<ip_address>:8080/batch with json_body {"tx_list": [{"operation": {"type": "SET_VALUE", "ref": "/db/path/to/set", "value": "testme"}}, {"operation": {"type": "SET_RULE", "ref": "/db/path/to/set2", "value": "some rule"}}]}
Four Node server with a Tracker server can be started all at once using start_servers.sh
like:
sh start_servers.sh
and can be stopped all at once using stop_servers.sh
like:
sh stop_servers.sh
Please read the CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under the MIT License - see the LICENSE file for details.