[#TxReconciliationTracker]
= TxReconciliationTracker
:mrdocs:

Transaction reconciliation is a way for nodes to efficiently announce transactions&period; This object keeps track of all txreconciliation&hyphen;related communications with the peers&period; The high&hyphen;level protocol is&colon; 0&period; Txreconciliation protocol handshake&period; 1&period; Once we receive a new transaction, add it to the set instead of announcing immediately&period; 2&period; At regular intervals, a txreconciliation initiator requests a sketch from a peer, where a sketch is a compressed representation of short form IDs of the transactions in their set&period; 3&period; Once the initiator received a sketch from the peer, the initiator computes a local sketch, and combines the two sketches to attempt finding the difference in _sets_&period; 4a&period; If the difference was not larger than estimated, see SUCCESS below&period; 4b&period; If the difference was larger than estimated, initial txreconciliation fails&period; The initiator requests a larger sketch via an extension round (allowed only once)&period; &hyphen; If extension succeeds (a larger sketch is sufficient), see SUCCESS below&period; &hyphen; If extension fails (a larger sketch is insufficient), see FAILURE below&period;

== Synopsis

Declared in `&lt;node&sol;txreconciliation&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class TxReconciliationTracker;
----

== Description

SUCCESS&period; The initiator knows full symmetrical difference and can request what the initiator is missing and announce to the peer what the peer is missing&period;

FAILURE&period; The initiator notifies the peer about the failure and announces all transactions from the corresponding set&period; Once the peer received the failure notification, the peer announces all transactions from their set&period;

This is a modification of the Erlay protocol (https&colon;&sol;&sol;arxiv&period;org&sol;abs&sol;1905&period;10518) with two changes (sketch extensions instead of bisections, and an extra INV exchange round), both are motivated in BIP&hyphen;330&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:TxReconciliationTracker/2constructor.adoc[`TxReconciliationTracker`]         [.small]#[constructor]#
| Construct a tracker speaking the given reconciliation protocol version&period;
| xref:TxReconciliationTracker/2destructor.adoc[`&#126;TxReconciliationTracker`] [.small]#[destructor]#
| Destroy the tracker and release all per&hyphen;peer reconciliation state&period;
| xref:TxReconciliationTracker/ForgetPeer.adoc[`ForgetPeer`] 
| Attempts to forget txreconciliation&hyphen;related state of the peer (if we previously stored any)&period; After this, we won&apos;t be able to reconcile transactions with the peer&period;
| xref:TxReconciliationTracker/IsPeerRegistered.adoc[`IsPeerRegistered`] 
| Check if a peer is registered to reconcile transactions with us&period;
| xref:TxReconciliationTracker/PreRegisterPeer.adoc[`PreRegisterPeer`] 
| Step 0&period; Generates initial part of the state (salt) required to reconcile txs with the peer&period; The salt is used for short ID computation required for txreconciliation&period; The function returns the salt&period; A peer can&apos;t participate in future txreconciliations without this call&period; This function must be called only once per peer&period;
| xref:TxReconciliationTracker/RegisterPeer.adoc[`RegisterPeer`] 
| Step 0&period; Once the peer agreed to reconcile txs with us, generate the state required to track ongoing reconciliations&period; Must be called only after pre&hyphen;registering the peer and only once&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
