mirror of
https://github.com/corda/corda.git
synced 2024-12-20 05:28:21 +00:00
439 lines
28 KiB
HTML
439 lines
28 KiB
HTML
|
||
|
||
<!DOCTYPE html>
|
||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||
<head>
|
||
<meta charset="utf-8">
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<title>Consensus model — R3 Corda latest documentation</title>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="top" title="R3 Corda latest documentation" href="index.html"/>
|
||
<link rel="next" title="Networking and messaging" href="messaging.html"/>
|
||
<link rel="prev" title="Data types" href="transaction-data-types.html"/>
|
||
|
||
|
||
<script src="_static/js/modernizr.min.js"></script>
|
||
|
||
</head>
|
||
|
||
<body class="wy-body-for-nav" role="document">
|
||
|
||
<div class="wy-grid-for-nav">
|
||
|
||
|
||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||
<div class="wy-side-scroll">
|
||
<div class="wy-side-nav-search">
|
||
|
||
|
||
|
||
|
||
<a href="index.html" class="icon icon-home"> R3 Corda
|
||
|
||
|
||
|
||
</a>
|
||
|
||
|
||
|
||
|
||
<div class="version">
|
||
latest
|
||
</div>
|
||
|
||
|
||
|
||
|
||
<div role="search">
|
||
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
|
||
<input type="text" name="q" placeholder="Search docs" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
||
|
||
<br>
|
||
<a href="api/index.html">API reference</a>
|
||
|
||
</div>
|
||
|
||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||
|
||
|
||
|
||
<p class="caption"><span class="caption-text">Overview</span></p>
|
||
<ul class="current">
|
||
<li class="toctree-l1"><a class="reference internal" href="inthebox.html">What’s included?</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="getting-set-up.html">Getting set up</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="data-model.html">Data model</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="transaction-data-types.html">Data types</a></li>
|
||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Consensus model</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="#notary">Notary</a><ul>
|
||
<li class="toctree-l3"><a class="reference internal" href="#multiple-notaries">Multiple notaries</a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#changing-notaries">Changing notaries</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#validation">Validation</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#timestamping">Timestamping</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#running-a-notary-service">Running a notary service</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#obtaining-a-signature">Obtaining a signature</a></li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1"><a class="reference internal" href="messaging.html">Networking and messaging</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="persistence.html">Persistence</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="creating-a-cordapp.html">Creating a Cordapp</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="creating-a-cordapp.html#gradle-plugins-for-cordapps">Gradle Plugins for Cordapps</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="creating-a-cordapp.html#template-build-gradle">Template build.gradle</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="creating-a-cordapp.html#cordformation">Cordformation</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="running-the-demos.html">Running the demos</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="node-administration.html">Node administration</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="corda-configuration-files.html">The Corda Configuration File</a></li>
|
||
</ul>
|
||
<p class="caption"><span class="caption-text">Tutorials</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="where-to-start.html">Where to start</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="tutorial-contract.html">Writing a contract</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="tutorial-contract-clauses.html">Writing a contract using clauses</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="tutorial-test-dsl.html">Writing a contract test</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="tutorial-clientrpc-api.html">Client RPC API</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="protocol-state-machines.html">Protocol state machines</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="oracles.html">Writing oracle services</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="tutorial-attachments.html">Using attachments</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="event-scheduling.html">Event scheduling</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="secure-coding-guidelines.html">Secure coding guidelines</a></li>
|
||
</ul>
|
||
<p class="caption"><span class="caption-text">Contracts</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="contract-catalogue.html">Contract catalogue</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="contract-irs.html">Interest Rate Swaps</a></li>
|
||
</ul>
|
||
<p class="caption"><span class="caption-text">Node API</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="clientrpc.html">Client RPC</a></li>
|
||
</ul>
|
||
<p class="caption"><span class="caption-text">Appendix</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="release-process.html">Release process</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="release-process.html#steps-to-cut-a-release">Steps to cut a release</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="release-notes.html">Release notes</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="network-simulator.html">Network Simulator</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="codestyle.html">Code style guide</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="building-the-docs.html">Building the documentation</a></li>
|
||
</ul>
|
||
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||
|
||
|
||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||
<a href="index.html">R3 Corda</a>
|
||
</nav>
|
||
|
||
|
||
|
||
<div class="wy-nav-content">
|
||
<div class="rst-content">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||
<ul class="wy-breadcrumbs">
|
||
<li><a href="index.html">Docs</a> »</li>
|
||
|
||
<li>Consensus model</li>
|
||
<li class="wy-breadcrumbs-aside">
|
||
|
||
|
||
<a href="_sources/consensus.txt" rel="nofollow"> View page source</a>
|
||
|
||
|
||
</li>
|
||
</ul>
|
||
<hr/>
|
||
</div>
|
||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
<div itemprop="articleBody">
|
||
|
||
<div class="section" id="consensus-model">
|
||
<h1>Consensus model<a class="headerlink" href="#consensus-model" title="Permalink to this headline">¶</a></h1>
|
||
<p>The fundamental unit of consensus in Corda is the <strong>state</strong>. The concept of consensus can be divided into two parts:</p>
|
||
<ol class="arabic simple">
|
||
<li>Consensus over state <strong>validity</strong> – parties can reach certainty that a transaction defining output states is accepted by the contracts pointed to by the states and has all the required signatures. This is achieved by parties independently running the same contract code and validation logic (as described in <a class="reference internal" href="data-model.html"><span class="doc">data model</span></a>)</li>
|
||
<li>Consensus over state <strong>uniqueness</strong> – parties can reach certainty the output states created in a transaction are the unique successors to the input states consumed by that transaction (in other words – a state has not been used as an input by more than one transaction)</li>
|
||
</ol>
|
||
<p>This article presents an initial model for addressing the <strong>uniqueness</strong> problem.</p>
|
||
<div class="admonition note">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">The current model is still a <strong>work in progress</strong> and everything described in this article can and is likely to change</p>
|
||
</div>
|
||
<div class="section" id="notary">
|
||
<h2>Notary<a class="headerlink" href="#notary" title="Permalink to this headline">¶</a></h2>
|
||
<p>We introduce the concept of a <strong>notary</strong>, which is an authority responsible for attesting that for a given transaction, it had not signed another transaction consuming any of its input states.
|
||
The data model is extended so that every <strong>state</strong> has an appointed notary:</p>
|
||
<div class="highlight-kotlin"><div class="highlight"><pre><span></span><span class="cm">/**</span>
|
||
<span class="cm"> * A wrapper for [ContractState] containing additional platform-level state information.</span>
|
||
<span class="cm"> * This is the definitive state that is stored on the ledger and used in transaction outputs</span>
|
||
<span class="cm"> */</span>
|
||
<span class="k">data</span> <span class="k">class</span> <span class="nc">TransactionState</span><span class="p"><</span><span class="k">out</span> <span class="n">T</span> <span class="p">:</span> <span class="n">ContractState</span><span class="p">>(</span>
|
||
<span class="cm">/** The custom contract state */</span>
|
||
<span class="k">val</span> <span class="py">data</span><span class="p">:</span> <span class="n">T</span><span class="p">,</span>
|
||
<span class="cm">/** Identity of the notary that ensures the state is not used as an input to a transaction more than once */</span>
|
||
<span class="k">val</span> <span class="py">notary</span><span class="p">:</span> <span class="n">Party</span><span class="p">)</span> <span class="p">{</span>
|
||
<span class="p">...</span>
|
||
<span class="p">}</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>All transactions have to be signed by their input state notary for the output states to be <strong>valid</strong> (apart from <em>issue</em> transactions, containing no input states).</p>
|
||
<div class="admonition note">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">The notary is a logical concept and can itself be a distributed entity, potentially a cluster maintained by mutually distrusting parties</p>
|
||
</div>
|
||
<p>When the notary is requested to sign a transaction, it either signs over it, attesting that the outputs are the <strong>unique</strong> successors of the inputs,
|
||
or provides conflict information for any input state that had been consumed by another transaction it had signed before.
|
||
In doing so, the notary provides the point of finality in the system. Until the notary signature is obtained, parties cannot be sure that an equally valid, but conflicting transaction,
|
||
will not be regarded as confirmed. After the signature is obtained, the parties know that the inputs to this transaction have been uniquely consumed by this transaction.
|
||
Hence it is the point at which we can say finality has occurred.</p>
|
||
<div class="section" id="multiple-notaries">
|
||
<h3>Multiple notaries<a class="headerlink" href="#multiple-notaries" title="Permalink to this headline">¶</a></h3>
|
||
<p>More than one notary can exist in the network. This gives the following benefits:</p>
|
||
<ul class="simple">
|
||
<li><strong>Custom behaviour</strong>. We can have both validating and privacy preserving Notaries – parties can make a choice based on their specific requirements</li>
|
||
<li><strong>Load balancing</strong>. Spreading the transaction load over multiple Notaries will allow higher transaction throughput in the platform overall</li>
|
||
<li><strong>Low latency</strong>. Latency could be minimised by choosing a notary physically closer the transacting parties</li>
|
||
</ul>
|
||
<p>A transaction should only be signed by a notary if all of its input states point to it.
|
||
In cases where a transaction involves states controlled by multiple notaries, the states first have to be repointed to the same notary.
|
||
This is achieved by using a special type of transaction that doesn’t modify anything but the notary pointer of the state.
|
||
Ensuring that all input states point to the same notary is the responsibility of each involved party
|
||
(it is another condition for an output state of the transaction to be <strong>valid</strong>)</p>
|
||
</div>
|
||
<div class="section" id="changing-notaries">
|
||
<h3>Changing notaries<a class="headerlink" href="#changing-notaries" title="Permalink to this headline">¶</a></h3>
|
||
<p>To change the notary for an input state, use the <code class="docutils literal"><span class="pre">NotaryChangeProtocol</span></code>. For example:</p>
|
||
<div class="highlight-kotlin"><div class="highlight"><pre><span></span><span class="n">@Suspendable</span>
|
||
<span class="k">fun</span> <span class="nf">changeNotary</span><span class="p">(</span><span class="n">originalState</span><span class="p">:</span> <span class="n">StateAndRef</span><span class="p"><</span><span class="n">ContractState</span><span class="p">>,</span>
|
||
<span class="n">newNotary</span><span class="p">:</span> <span class="n">Party</span><span class="p">):</span> <span class="n">StateAndRef</span><span class="p"><</span><span class="n">ContractState</span><span class="p">></span> <span class="p">{</span>
|
||
<span class="k">val</span> <span class="py">protocol</span> <span class="p">=</span> <span class="n">NotaryChangeProtocol</span><span class="p">.</span><span class="n">Instigator</span><span class="p">(</span><span class="n">originalState</span><span class="p">,</span> <span class="n">newNotary</span><span class="p">)</span>
|
||
<span class="k">return</span> <span class="n">subProtocol</span><span class="p">(</span><span class="n">protocol</span><span class="p">)</span>
|
||
<span class="p">}</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The protocol will:</p>
|
||
<ol class="arabic simple">
|
||
<li>Construct a transaction with the old state as the input and the new state as the output</li>
|
||
<li>Obtain signatures from all <em>participants</em> (a participant is any party that is able to consume this state in a valid transaction, as defined by the state itself)</li>
|
||
<li>Obtain the <em>old</em> notary signature</li>
|
||
<li>Record and distribute the final transaction to the participants so that everyone possesses the new state</li>
|
||
</ol>
|
||
<div class="admonition note">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">Eventually this will be handled automatically on demand.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="validation">
|
||
<h2>Validation<a class="headerlink" href="#validation" title="Permalink to this headline">¶</a></h2>
|
||
<p>One of the design decisions for a notary is whether or not to <strong>validate</strong> a transaction before committing its input states.</p>
|
||
<p>If a transaction is not checked for validity, it opens the platform to “denial of state” attacks, where anyone can build an invalid transaction consuming someone else’s states and submit it to the notary to get the states “blocked”.
|
||
However, validation of a transaction requires the notary to be able to see the full contents of the transaction in question and its dependencies.
|
||
This is an obvious privacy leak.</p>
|
||
<p>Our platform is flexible and we currently support both validating and non-validating notary implementations – a party can select which one to use based on its own privacy requirements.</p>
|
||
<div class="admonition note">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">In the non-validating model the “denial of state” attack is partially alleviated by requiring the calling
|
||
party to authenticate and storing its identity for the request. The conflict information returned by the notary
|
||
specifies the consuming transaction ID along with the identity of the party that had requested the commit. If the
|
||
conflicting transaction is valid, the current one gets aborted; if not – a dispute can be raised and the input states
|
||
of the conflicting invalid transaction are “un-committed” (to be covered by legal process).</p>
|
||
</div>
|
||
<div class="admonition note">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">At present all notaries can see the entire contents of a transaction, but we have a separate piece of work to
|
||
replace the parts of the transaction it does not require knowing about with hashes (only input references, timestamp
|
||
information, overall transaction ID and the necessary digests of the rest of the transaction to prove that the
|
||
referenced inputs/timestamps really do form part of the stated transaction ID should be visible).</p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="timestamping">
|
||
<h2>Timestamping<a class="headerlink" href="#timestamping" title="Permalink to this headline">¶</a></h2>
|
||
<p>In this model the notary also acts as a <em>timestamping authority</em>, verifying the transaction timestamp command.</p>
|
||
<p>For a timestamp to be meaningful, its implications must be binding on the party requesting it.
|
||
A party can obtain a timestamp signature in order to prove that some event happened before/on/or after a particular point in time.
|
||
However, if the party is not also compelled to commit to the associated transaction, it has a choice of whether or not to reveal this fact until some point in the future.
|
||
As a result, we need to ensure that the notary either has to also sign the transaction within some time tolerance,
|
||
or perform timestamping <em>and</em> notarisation at the same time, which is the chosen behaviour for this model.</p>
|
||
<p>There will never be exact clock synchronisation between the party creating the transaction and the notary.
|
||
This is not only due to physics, network latencies etc but because between inserting the command and getting the
|
||
notary to sign there may be many other steps, like sending the transaction to other parties involved in the trade
|
||
as well, or even requesting human signoff. Thus the time observed by the notary may be quite different to the
|
||
time observed in step 1.</p>
|
||
<p>For this reason, times in transactions are specified as time <em>windows</em>, not absolute times. Time windows can be
|
||
open-ended, i.e. specify only one of “before” and “after” or they can be fully bounded. If a time window needs to
|
||
be converted to an absolute time for e.g. display purposes, there is a utility method on <code class="docutils literal"><span class="pre">Timestamp</span></code> to
|
||
calculate the mid point - but in a distributed system there can never be “true time”, only an approximation of it.</p>
|
||
<p>In this way we express that the <em>true value</em> of the fact “the current time” is actually unknowable. Even when both before and
|
||
after times are included, the transaction could have occurred at any point between those two timestamps. Here
|
||
“occurrence” could mean the execution date, the value date, the trade date etc ... the notary doesn’t care what precise
|
||
meaning the timestamp has to the contract.</p>
|
||
<p>By creating a range that can be either closed or open at one end, we allow all of the following facts to be modelled:</p>
|
||
<ul class="simple">
|
||
<li>This transaction occurred at some point after the given time (e.g. after a maturity event)</li>
|
||
<li>This transaction occurred at any time before the given time (e.g. before a bankruptcy event)</li>
|
||
<li>This transaction occurred at some point roughly around the given time (e.g. on a specific day)</li>
|
||
</ul>
|
||
<div class="admonition note">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">It is assumed that the time feed for a notary is GPS/NaviStar time as defined by the atomic
|
||
clocks at the US Naval Observatory. This time feed is extremely accurate and available globally for free.</p>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="running-a-notary-service">
|
||
<h2>Running a notary service<a class="headerlink" href="#running-a-notary-service" title="Permalink to this headline">¶</a></h2>
|
||
<p>At present we have two basic implementations that store committed input states in memory:</p>
|
||
<ul class="simple">
|
||
<li><code class="docutils literal"><span class="pre">SimpleNotaryService</span></code> – commits the provided transaction without any validation</li>
|
||
<li><code class="docutils literal"><span class="pre">ValidatingNotaryService</span></code> – retrieves and validates the whole transaction history (including the given transaction) before committing</li>
|
||
</ul>
|
||
</div>
|
||
<div class="section" id="obtaining-a-signature">
|
||
<h2>Obtaining a signature<a class="headerlink" href="#obtaining-a-signature" title="Permalink to this headline">¶</a></h2>
|
||
<p>Once a transaction is built and ready to be finalised, normally you would call <code class="docutils literal"><span class="pre">FinalityProtocol</span></code> passing in a
|
||
<code class="docutils literal"><span class="pre">SignedTransaction</span></code> (including signatures from the participants) and a list of participants to notify. This requests a
|
||
notary signature if needed, and then sends a copy of the notarised transaction to all participants for them to store.
|
||
<code class="docutils literal"><span class="pre">FinalityProtocol</span></code> delegates to <code class="docutils literal"><span class="pre">NotaryProtocol.Client</span></code> followed by <code class="docutils literal"><span class="pre">BroadcastTransactionProtocol</span></code> to do the
|
||
actual work of notarising and broadcasting the transaction. For example:</p>
|
||
<div class="highlight-kotlin"><div class="highlight"><pre><span></span><span class="k">fun</span> <span class="nf">finaliseTransaction</span><span class="p">(</span><span class="n">serviceHub</span><span class="p">:</span> <span class="n">ServiceHubInternal</span><span class="p">,</span> <span class="n">ptx</span><span class="p">:</span> <span class="n">TransactionBuilder</span><span class="p">,</span> <span class="n">participants</span><span class="p">:</span> <span class="n">Set</span><span class="p"><</span><span class="n">Party</span><span class="p">>)</span>
|
||
<span class="p">:</span> <span class="n">ListenableFuture</span><span class="p"><</span><span class="n">Unit</span><span class="p">></span> <span class="p">{</span>
|
||
<span class="c1">// We conclusively cannot have all the signatures, as the notary has not signed yet</span>
|
||
<span class="k">val</span> <span class="py">tx</span> <span class="p">=</span> <span class="n">ptx</span><span class="p">.</span><span class="n">toSignedTransaction</span><span class="p">(</span><span class="n">checkSufficientSignatures</span> <span class="p">=</span> <span class="k">false</span><span class="p">)</span>
|
||
<span class="c1">// The empty set would be the trigger events, which are not used here</span>
|
||
<span class="k">val</span> <span class="py">protocol</span> <span class="p">=</span> <span class="n">FinalityProtocol</span><span class="p">(</span><span class="n">tx</span><span class="p">,</span> <span class="n">emptySet</span><span class="p">(),</span> <span class="n">participants</span><span class="p">)</span>
|
||
<span class="k">return</span> <span class="n">serviceHub</span><span class="p">.</span><span class="n">startProtocol</span><span class="p">(</span><span class="s">"protocol.finalisation"</span><span class="p">,</span> <span class="n">protocol</span><span class="p">)</span>
|
||
<span class="p">}</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>To manually obtain a signature from a notary you can call <code class="docutils literal"><span class="pre">NotaryProtocol.Client</span></code> directly. The protocol will work out
|
||
which notary needs to be called based on the input states and the timestamp command. For example, the following snippet
|
||
can be used when writing a custom protocol:</p>
|
||
<div class="highlight-kotlin"><div class="highlight"><pre><span></span><span class="k">fun</span> <span class="nf">getNotarySignature</span><span class="p">(</span><span class="n">wtx</span><span class="p">:</span> <span class="n">WireTransaction</span><span class="p">):</span> <span class="n">DigitalSignature</span><span class="p">.</span><span class="n">LegallyIdentifiable</span> <span class="p">{</span>
|
||
<span class="k">return</span> <span class="n">subProtocol</span><span class="p">(</span><span class="n">NotaryProtocol</span><span class="p">.</span><span class="n">Client</span><span class="p">(</span><span class="n">wtx</span><span class="p">))</span>
|
||
<span class="p">}</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>On conflict the <code class="docutils literal"><span class="pre">NotaryProtocol</span></code> with throw a <code class="docutils literal"><span class="pre">NotaryException</span></code> containing the conflict details:</p>
|
||
<div class="highlight-kotlin"><div class="highlight"><pre><span></span><span class="cm">/** Specifies the consuming transaction for the conflicting input state */</span>
|
||
<span class="k">data</span> <span class="k">class</span> <span class="nc">Conflict</span><span class="p">(</span><span class="k">val</span> <span class="py">stateHistory</span><span class="p">:</span> <span class="n">Map</span><span class="p"><</span><span class="n">StateRef</span><span class="p">,</span> <span class="n">ConsumingTx</span><span class="p">>)</span>
|
||
|
||
<span class="cm">/**</span>
|
||
<span class="cm"> * Specifies the transaction id, the position of the consumed state in the inputs, and</span>
|
||
<span class="cm"> * the caller identity requesting the commit</span>
|
||
<span class="cm"> */</span>
|
||
<span class="k">data</span> <span class="k">class</span> <span class="nc">ConsumingTx</span><span class="p">(</span><span class="k">val</span> <span class="py">id</span><span class="p">:</span> <span class="n">SecureHash</span><span class="p">,</span> <span class="k">val</span> <span class="py">inputIndex</span><span class="p">:</span> <span class="n">Int</span><span class="p">,</span> <span class="k">val</span> <span class="py">requestingParty</span><span class="p">:</span> <span class="n">Party</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Conflict handling and resolution is currently the responsibility of the protocol author.</p>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<footer>
|
||
|
||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||
|
||
<a href="messaging.html" class="btn btn-neutral float-right" title="Networking and messaging" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||
|
||
|
||
<a href="transaction-data-types.html" class="btn btn-neutral" title="Data types" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||
|
||
</div>
|
||
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>
|
||
© Copyright 2016, Distributed Ledger Group, LLC.
|
||
|
||
</p>
|
||
</div>
|
||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||
|
||
</footer>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</section>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript">
|
||
var DOCUMENTATION_OPTIONS = {
|
||
URL_ROOT:'./',
|
||
VERSION:'latest',
|
||
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>
|
||
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript" src="_static/js/theme.js"></script>
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript">
|
||
jQuery(function () {
|
||
SphinxRtdTheme.StickyNav.enable();
|
||
});
|
||
</script>
|
||
|
||
|
||
</body>
|
||
</html> |