Transaction mechanisms
In the following two sections, we will discuss the two key transaction mechanisms related to contract design and implementation, specifically the ReadSet
and WriteSet
structures used to record information into transactions and the multiversion concurrency control used to ensure consistency between transactions.
The ReadSet and WriteSet
On receipt of a transaction invocation message from a client, the endorsing peer executes a transaction. The execution invokes the contract in the context of the peer's Worldstate
and records all reads and writes of its data on the ledger into a ReadSet
and WriteSet
.
The transaction's WriteSet
contains a list of key and value pairs that were modified during the execution by the contract. When the value of a key is modified by a putState
function (that is, a new key and value are recorded or an existing key is updated with a new value), the WriteSet
will contain the updated key and value pair.
When a...