Docker container for the Avalon block chain
8.6K
npm install to install nodejs dependenciesnode src/cli.js keypairscripts/start.shchmod +x scripts/start.sh./scripts/start.shThe start.sh shows the list of available environment variables you can set to make avalon behave slightly differently from the default install.
Shut everything down, then db.dropDatabase() in mongo, and start the node. This will do a complete replay and verification of the chain. Depending on your CPU/RAM it might be extremely slow and take a long time on a long chain with many transactions.
An alternative way to resync your node faster is to use one of the backups provided by backup.d.tube. Example:
wget https://backup.d.tube/16.tar.gz
tar xfvz ./16.tar.gz
mongorestore -d avalon .
Will download and restore your avalon node up to 16:00 UTC.
Alternatively, if you do not want to have to trust our backups, feel free to create your own as such:
mongodump -d avalon -o ~/avalon-backup/
It is strongly recommended for all leaders to add a node.ws field to your profile as so:
node src/cli.js profile -K <key> -M <user> '{"node":{"ws":"ws://yourip:yourport"}}'
We have a discord channel dedicated to node owners (aka leaders), where you can get support to get set up. Join discorg.gg/dtube and go to DTube Chain -> #leader-candidates
You can use the CLI tool to transact with avalon. Simply try node src/cli --help or node src/cli <command> --help for a full help.
Javalon is the javascript wrapper for avalon's API. Working on both browser and nodejs.
Avalon's API uses 100% JSON. The GET calls will allow you to fetch the public information which is already available through the d.tube UI.
Examples:
This lists all the available API endpoints for Avalon. We also have recommended security practises if you want to open your node's API to the world. You can do it easily with nginx and avalon-nginx-config
Once you have an account and balance, your account will start generating bandwidth and voting power (respectively the bw and vt fields in your account data). You can consume those ressources by transacting.
Every transactions will have a bandwidth cost, calculated based on the number of bytes required for the storage of fyour transaction in a block. Certain transaction types will require you to spend voting power, such as publishing a content, voting or tagging a content.
To transact, you need to use the /transact POST call of the Avalon API.
Necessary for all transactions:
node src/cli.js vote-leader -K <key> -M <user> <target>
// alice votes for bob as a leader
node src/cli.js vote-leader -K 5DPwDJqTvMuykHimmZxThfKttPSNLzJjpbNtkGNnjPAf -M alice bob
node src/cli.js vote-leader -K <key> -M <user> <target>
// charlie does not want to vote for daniel as a leader anymore
node src/cli.js unvote-leader -F charlie_key.txt -M charlie daniel
node src/cli.js transfer -K <bob_key> -M <user> <receiver> <amount> <memo>
// bob sends 50 DTC to charles
node src/cli.js transfer -K HkUbQ5YpejWVSPt8Qgz8pkPGwkDrMn3XECd4Asn3ANB3 -M bob charles 50 'thank you'
{"string":"aye", array:[1,2,3]}node src/cli.js comment -K <key> -M <user> <link> <parent_author> <parent_link> <json>
node src/cli.js vote -K <key> -M <user> <link> <author> <weight> <tag>
{"string":"aye", array:[1,2,3]}node src/cli.js profile -K <key> -M <user> <json>
node src/cli.js follow -K <key> -M <user> <target>
node src/cli.js unfollow -K <key> -M <user> <target>
To create a transaction and export it to a file, you can use the sign CLI tool
node src/cli.js sign <priv_key> <user> <tx> > tmptx.json
For example to approve a node owner and publishing it only 5 seconds later:
node src/cli.js sign -K 4L1C3553KRETK3Y -M alice '{"type":1,"data":{"target":"miner1"}}' > tmptx.json
sleep 5
curl -H "Content-type:application/json" --data @tmptx.json http://localhost:3001/transact
Will force the node to try to produce a block even if it's unscheduled. Useful for block #1 and working on development
curl http://localhost:3001/mineBlock
Manually force connection to a peer without having to restart the node
curl -H "Content-type:application/json" --data '{"peer" : "ws://localhost:6001"}' http://localhost:3001/addPeer
Avalon saves the state of the chain into mongodb after each block. You can easily query mongodb directly to get any data you want, that wouldn't be provided by the API itself.
mongo <db_name>
db.accounts.findOne({name:'master'})
db.blocks.findOne({_id: 0})
However be sure not to write to any collection used by avalon in this database (namely the accounts, blocks and contents). If you do, your node will irremediably fork sooner or later.
Avalon can also copy the accounts and contents into an elastic search database with monstache. A configuration file for monstache is provided in the root of this repository. Once running you can do text queries on accounts or contents like so:
# search contents
curl http://localhost:9200/avalon.contents/_search?q=football
# search accounts
curl http://localhost:9200/avalon.accounts/_search?q=satoshi
Please refer to Elastic Search documentation for more complex queries.
D.Tube runs a public Elastic Search mirror of the current testnet on https://search.d.tube
Content type
Image
Digest
Size
77.3 MB
Last updated
about 7 years ago
docker pull nannal/avalon