README.md in zold-0.6.3 vs README.md in zold-0.6.4

- old
+ new

@@ -15,10 +15,14 @@ [![Maintainability](https://api.codeclimate.com/v1/badges/7489c1d2bacde40ffc09/maintainability)](https://codeclimate.com/github/zerocracy/zold/maintainability) **NOTICE**: It's an experiment and a very early draft! Please, feel free to submit your ideas or pull requests. +Here is the [White Paper](https://latexonline.cc/compile?git=https%3A%2F%2Fgithub.com%2Fyegor256%2Fzold&target=wp%2Fwp.tex&command=pdflatex&trackId=1520158941887). + +The license is [MIT](https://github.com/zerocracy/zold/blob/master/LICENSE.txt). + ## How to Use Install Ruby 2.2+, [Rubygems](https://rubygems.org/pages/download), and then run: ```bash @@ -36,141 +40,56 @@ ```bash $ zold --help ``` -You will need PGP keys in `~/.ssh`. To generate them, if you don't have them -yet, you can run: +You will need PGP keys in `~/.ssh`. To generate them (if you don't have them yet): ```bash $ ssh-keygen -t rsa -b 4096 ``` -### Remote +First, create a wallet (instead of `5f96e731e48ae21f` there will be your +person wallet number, use it everywhere below): -Each node maintains a list of visible "remote" nodes. -The gem is shipped together with a hard-coded list of a few of them. +```bash +$ zold create +5f96e731e48ae21f +``` - * `remote update` goes through the list of all remote nodes, - checks their availability, and either removes them from the list or - adds new nodes to the list. +Then, give its number to your friend, who is going to pay you. +When the payment is sent, ask him or her for the number of the wallet +the payment has been sent from and then fetch that wallet +(let's say it is `5555444433332222`): - * `remote add <IP>` adds a new remote node to the list. +```bash +$ zold fetch 5555444433332222 +5.00 ZLD added to 5f96e731e48ae21f: To my friend! +``` - * `remote remove <IP>` removes a remote node. +Now, you have the money in your wallet! - * `remote show` prints the entire list of remote nodes. +Next, you can pay your friend back: -The node always tries to make sure the summary of all scores in the -list of remote nodes is right above the MSS, but not more. - -### Fetch - -The node attempts to pull the wallet from the first remote. -The remote returns the wallet, if it exists. Otherwise, rejects the request -and returns the list of all remotes known to it. - -The node stores the content of the wallet and the score of the remote -to the local storage. -The local storage doesn't keep all remote copies, but only their unique -versions and summary scores for each version. - -Fetching stops when: - - * Total score is above MSS _or_ - * There is only one version and the total score is above ½ MSS. - -If not, the node attempts the next remote in the list. - -### Merge - -The remote copy is accepted "as is" without verifications if: - - * All remote copies are identical _and_ - * Their summary score is above the MSS. - -Otherwise, the node goes through the entire list of transactions visible in all -remote copies and merges them one by one into the "head" copy. -The decision is made per each transaction. - -If a transaction exists in the head, it remains there. - -Otherwise, if it's a positive transaction that increases the balance of the head copy, -the signature is validated (in the paying wallet, which is pulled first) -and it goes into the head. The transaction gets a new ID. - -If it's a negative transaction, the decision is made between all copies. -The one with the largest score goes first, if the balance of the wallet -is big enough. Then, the next one in the line and so on. The transactions -that negate the balance are rejected. - -### Pay - -The node pulls both wallets. Then, say, the user makes a payment -from the wallet `0123456789abcdef` to the wallet `4567456745674567`: - ```bash -zold send 0123456789abcdef 4567456745674567 5 +$ zold pay 5f96e731e48ae21f 5555444433332222 2.50 'Here is a refund' +-2.50 ZLD added to 5f96e731e48ae21f: Here is a refund ``` -The content of both files get changed. An outgoing transaction with a negative -amount gets added to the end of the paying wallet `0123456789abcdef`: +Finally, you have to push your wallet to the network so that your friend +knows about the payment: -```text -500;2017-07-19T22:18:43Z;-83886080;4567456745674567;-;b6SKMPrVjLx... +```bash +$ zold push 5f96e731e48ae21f ``` -The incoming transaction gets appended to the end of the receiving wallet -`4567456745674567`: +That's it. -```text -500;2017-07-19T22:18:43Z;83886080;0123456789abcdef;- +You also can contribute to Zold by running a node on your server. +In order to do that just run: + +```bash +$ zold node --invoice=5f96e731e48ae21f ``` -### Push - -The node sends a package of a few wallets to the biggest remote available -(with the highest score). -The package must also include a fee to the wallet that belongs to the -remote. - -The remote stores them as remote copies and performs _pull_. - -The remote sends "pull requests" to all available nodes. -They must pull from the node for free, if their scores are lower or equal -to the score of the node. - -## RESTful API - -The full list of RESTful resources: - - * `/` (GET): status page of the node, in JSON - - * `/remotes` (GET): load all known remotes in JSON - - * `/wallet/<ID>` (GET): fetch wallet in JSON - - * `/wallet/<ID>` (PUT): push wallet - -Each HTTP response contains `Content-type` header. - -## Files - - -`.zold/remotes` is a comma-separated file with a list of remote nodes with -these columns: - - * Address or IP; - * TCP port (usually 4096); - * Score (positive integer); - * Time of score update, ISO 8601. - -`.zold/copies` is a directory of directories, named after wallet IDs, -each of which contains copies of wallets, named like `1`, `2`, `3`, etc. Also, -each sub-directory contains a comma-separated file `scores` with these columns: - - * The name of the copy, e.g. `1`; - * The address of the remote (host name or IP); - * The TCP port number of the remote; - * The score (positive integer); - * The time of fetching, in ISO 8601. - +Grateful users of the system will pay "taxes" to your wallet for processing +of their transactions.