mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-06-24 10:16:43 +02:00
199 lines
12 KiB
HTML
199 lines
12 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>10. The Transaction, Block and Vote Models — Bigchain 0.0.1 documentation</title>
|
|
|
|
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: './',
|
|
VERSION: '0.0.1',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
<link rel="top" title="Bigchain 0.0.1 documentation" href="index.html" />
|
|
<link rel="next" title="11. JSON Serialization" href="json-serialization.html" />
|
|
<link rel="prev" title="9. Cryptography" href="cryptography.html" />
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
|
|
|
|
</head>
|
|
<body role="document">
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body" role="main">
|
|
|
|
<div class="section" id="the-transaction-block-and-vote-models">
|
|
<span id="the-transaction-block-and-vote-models"></span><h1>10. The Transaction, Block and Vote Models<a class="headerlink" href="#the-transaction-block-and-vote-models" title="Permalink to this headline">¶</a></h1>
|
|
<p>Transactions, blocks and votes are represented using JSON documents with the following models (schemas).</p>
|
|
<div class="section" id="the-transaction-model">
|
|
<span id="the-transaction-model"></span><h2>10.1. The Transaction Model<a class="headerlink" href="#the-transaction-model" title="Permalink to this headline">¶</a></h2>
|
|
<div class="highlight-python"><div class="highlight"><pre>{
|
|
"id": "<sha3 hash>",
|
|
"transaction": {
|
|
"current_owner": "<pub-key>",
|
|
"new_owner": "<pub-key>",
|
|
"input": "<sha3 hash>",
|
|
"operation": "<string>",
|
|
"timestamp": "<rethinkdb timestamp>",
|
|
"data": {
|
|
"hash": "<sha3 hash>",
|
|
...
|
|
}
|
|
},
|
|
"signature": "<ECDSA signature of the transaction>"
|
|
}
|
|
</pre></div>
|
|
</div>
|
|
<p>A transaction is an operation between the <code class="docutils literal"><span class="pre">current_owner</span></code> and the <code class="docutils literal"><span class="pre">new_owner</span></code> over the digital content described by <code class="docutils literal"><span class="pre">hash</span></code>. For example if could be a transfer of ownership of the digital content <code class="docutils literal"><span class="pre">hash</span></code></p>
|
|
<ul class="simple">
|
|
<li><code class="docutils literal"><span class="pre">id</span></code>: sha3 hash of the transaction and rethinkdb primary key. By using the hash of the transaction of the
|
|
primary key we eliminate the problem of duplicated transactions, if for some reason two nodes decide to create the
|
|
same transaction</li>
|
|
<li><code class="docutils literal"><span class="pre">current_owner</span></code>: Public key of the current owner of the digital content with hash <code class="docutils literal"><span class="pre">hash</span></code></li>
|
|
<li><code class="docutils literal"><span class="pre">new_owner</span></code>: Public key of the new owner of the digital content with hash <code class="docutils literal"><span class="pre">hash</span></code></li>
|
|
<li><code class="docutils literal"><span class="pre">input</span></code>: sha3 hash of the transaction in which the content was transfered to the user (similar to input in
|
|
the blockchain). Right now we will assume that there is only one input per transaction to simplify the prototype.
|
|
This can be changed in the future to allow multiple inputs per transaction.</li>
|
|
<li><code class="docutils literal"><span class="pre">operation</span></code>: String representation of the operation being performed (REGISTER, TRANSFER, ...) this will define how
|
|
the transactions should be validated</li>
|
|
<li><code class="docutils literal"><span class="pre">timestamp</span></code>: Time of creation of the transaction in UTC</li>
|
|
<li><code class="docutils literal"><span class="pre">data</span></code>: Json object describing the asset (digital content). It contains at least the field <code class="docutils literal"><span class="pre">hash</span></code> which is a
|
|
sha3 hash of the digital content.</li>
|
|
<li><code class="docutils literal"><span class="pre">signature</span></code>: ECDSA signature of the transaction with the <code class="docutils literal"><span class="pre">current_owner</span></code> private key</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="the-block-model">
|
|
<span id="the-block-model"></span><h2>10.2. The Block Model<a class="headerlink" href="#the-block-model" title="Permalink to this headline">¶</a></h2>
|
|
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
|
|
<span class="nt">"id"</span><span class="p">:</span> <span class="s2">"<sha3 hash of the list of transactions + timestamp + nodes_pubkeys>"</span><span class="p">,</span>
|
|
<span class="nt">"block"</span><span class="p">:</span> <span class="p">{</span>
|
|
<span class="nt">"timestamp"</span><span class="p">:</span> <span class="s2">"<RethinkDB timestamp>"</span><span class="p">,</span>
|
|
<span class="nt">"transactions"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"<list of transactions>"</span><span class="p">],</span>
|
|
<span class="nt">"node_pubkey"</span><span class="p">:</span> <span class="s2">"<public key of the node creating the block>"</span><span class="p">,</span>
|
|
<span class="nt">"voters"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"<list of federation nodes pulic keys>"</span><span class="p">]</span>
|
|
<span class="p">},</span>
|
|
<span class="nt">"signature"</span><span class="p">:</span> <span class="s2">"<signature of the block>"</span><span class="p">,</span>
|
|
<span class="nt">"votes"</span><span class="p">:</span> <span class="p">[]</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Still to be defined when new blocks are created (after x number of transactions, or after x amount of seconds,
|
|
or both).
|
|
A block contains a group of transactions and includes the hash of the hash of the previous block to build the chain.</p>
|
|
<ul class="simple">
|
|
<li><code class="docutils literal"><span class="pre">id</span></code>: sha3 hash of the current block. This is also a rethinkdb primary key, this way we make sure that all blocks are unique.</li>
|
|
<li><code class="docutils literal"><span class="pre">block</span></code>: The actual block<ul>
|
|
<li><code class="docutils literal"><span class="pre">timestamp</span></code>: timestamp when the block was created</li>
|
|
<li><code class="docutils literal"><span class="pre">transactions</span></code>: the list of transactions included in the block</li>
|
|
<li><code class="docutils literal"><span class="pre">node_pubkey</span></code>: the public key of the node that create the block</li>
|
|
<li><code class="docutils literal"><span class="pre">voters</span></code>: list public keys of the federation nodes. Since the size of the
|
|
federation may change over time this will tell us how many nodes existed
|
|
in the federation when the block was created so that in a later point in
|
|
time we can check that the block received the correct number of votes.</li>
|
|
</ul>
|
|
</li>
|
|
<li><code class="docutils literal"><span class="pre">signature</span></code>: Signature of the block by the node that created the block</li>
|
|
<li><code class="docutils literal"><span class="pre">votes</span></code>: Initially an empty list. Nodes in the voters list will append to it
|
|
has they vote on the block</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="the-vote-model">
|
|
<span id="the-vote-model"></span><h2>10.3. The Vote Model<a class="headerlink" href="#the-vote-model" title="Permalink to this headline">¶</a></h2>
|
|
<p>This is the structure that each node will append to the block <code class="docutils literal"><span class="pre">votes</span></code> list.</p>
|
|
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span>
|
|
<span class="nt">"node_pubkey"</span><span class="p">:</span> <span class="s2">"<the pubkey of the voting node>"</span><span class="p">,</span>
|
|
<span class="nt">"vote"</span><span class="p">:</span> <span class="p">{</span>
|
|
<span class="nt">"voting_for_block"</span><span class="p">:</span> <span class="s2">"<id of the block the node is voting for>"</span><span class="p">,</span>
|
|
<span class="nt">"previous_block"</span><span class="p">:</span> <span class="s2">"<id of the block previous to this one>"</span><span class="p">,</span>
|
|
<span class="nt">"is_block_valid"</span><span class="p">:</span> <span class="s2">"<true|false>"</span><span class="p">,</span>
|
|
<span class="nt">"invalid_reason"</span><span class="p">:</span> <span class="s2">"<None|DOUBLE_SPEND|TRANSACTIONS_HASH_MISMATCH|NODES_PUBKEYS_MISMATCH"</span><span class="p">,</span>
|
|
<span class="nt">"timestamp"</span><span class="p">:</span> <span class="s2">"<rethinkdb timestamp of the voting action>"</span>
|
|
<span class="p">},</span>
|
|
<span class="nt">"signature"</span><span class="p">:</span> <span class="s2">"<ECDSA signature of vote block>"</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
|
<div class="sphinxsidebarwrapper">
|
|
<h3><a href="index.html">Table Of Contents</a></h3>
|
|
<ul>
|
|
<li><a class="reference internal" href="#">10. The Transaction, Block and Vote Models</a><ul>
|
|
<li><a class="reference internal" href="#the-transaction-model">10.1. The Transaction Model</a></li>
|
|
<li><a class="reference internal" href="#the-block-model">10.2. The Block Model</a></li>
|
|
<li><a class="reference internal" href="#the-vote-model">10.3. The Vote Model</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<div class="relations">
|
|
<h3>Related Topics</h3>
|
|
<ul>
|
|
<li><a href="index.html">Documentation overview</a><ul>
|
|
<li>Previous: <a href="cryptography.html" title="previous chapter">9. Cryptography</a></li>
|
|
<li>Next: <a href="json-serialization.html" title="next chapter">11. JSON Serialization</a></li>
|
|
</ul></li>
|
|
</ul>
|
|
</div>
|
|
<div role="note" aria-label="source link">
|
|
<h3>This Page</h3>
|
|
<ul class="this-page-menu">
|
|
<li><a href="_sources/models.txt"
|
|
rel="nofollow">Show Source</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="searchbox" style="display: none" role="search">
|
|
<h3>Quick search</h3>
|
|
<form class="search" action="search.html" method="get">
|
|
<input type="text" name="q" />
|
|
<input type="submit" value="Go" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
<p class="searchtip" style="font-size: 90%">
|
|
Enter search terms or a module, class or function name.
|
|
</p>
|
|
</div>
|
|
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="footer">
|
|
©2016, ascribe GmbH.
|
|
|
|
|
|
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.3.5</a>
|
|
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.7</a>
|
|
|
|
|
|
|
<a href="_sources/models.txt"
|
|
rel="nofollow">Page source</a>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
</html> |