1
0
mirror of https://github.com/bigchaindb/bigchaindb.git synced 2024-06-24 10:16:43 +02:00
bigchaindb/docs/build/html/models.html
2016-02-09 19:16:18 +01:00

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 &mdash; 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>{
&quot;id&quot;: &quot;&lt;sha3 hash&gt;&quot;,
&quot;transaction&quot;: {
&quot;current_owner&quot;: &quot;&lt;pub-key&gt;&quot;,
&quot;new_owner&quot;: &quot;&lt;pub-key&gt;&quot;,
&quot;input&quot;: &quot;&lt;sha3 hash&gt;&quot;,
&quot;operation&quot;: &quot;&lt;string&gt;&quot;,
&quot;timestamp&quot;: &quot;&lt;rethinkdb timestamp&gt;&quot;,
&quot;data&quot;: {
&quot;hash&quot;: &quot;&lt;sha3 hash&gt;&quot;,
...
}
},
&quot;signature&quot;: &quot;&lt;ECDSA signature of the transaction&gt;&quot;
}
</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">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;sha3 hash of the list of transactions + timestamp + nodes_pubkeys&gt;&quot;</span><span class="p">,</span>
<span class="nt">&quot;block&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">&quot;timestamp&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;RethinkDB timestamp&gt;&quot;</span><span class="p">,</span>
<span class="nt">&quot;transactions&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s2">&quot;&lt;list of transactions&gt;&quot;</span><span class="p">],</span>
<span class="nt">&quot;node_pubkey&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;public key of the node creating the block&gt;&quot;</span><span class="p">,</span>
<span class="nt">&quot;voters&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s2">&quot;&lt;list of federation nodes pulic keys&gt;&quot;</span><span class="p">]</span>
<span class="p">},</span>
<span class="nt">&quot;signature&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;signature of the block&gt;&quot;</span><span class="p">,</span>
<span class="nt">&quot;votes&quot;</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">&quot;node_pubkey&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;the pubkey of the voting node&gt;&quot;</span><span class="p">,</span>
<span class="nt">&quot;vote&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">&quot;voting_for_block&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;id of the block the node is voting for&gt;&quot;</span><span class="p">,</span>
<span class="nt">&quot;previous_block&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;id of the block previous to this one&gt;&quot;</span><span class="p">,</span>
<span class="nt">&quot;is_block_valid&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;true|false&gt;&quot;</span><span class="p">,</span>
<span class="nt">&quot;invalid_reason&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;None|DOUBLE_SPEND|TRANSACTIONS_HASH_MISMATCH|NODES_PUBKEYS_MISMATCH&quot;</span><span class="p">,</span>
<span class="nt">&quot;timestamp&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;rethinkdb timestamp of the voting action&gt;&quot;</span>
<span class="p">},</span>
<span class="nt">&quot;signature&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;ECDSA signature of vote block&gt;&quot;</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">
&copy;2016, ascribe GmbH.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.3.5</a>
&amp; <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>