B Counter
A delta-based CRDT bounded-counter (non-negative, initially 0).
Following design from V. Balegas et al., "Extending Eventually Consistent Cloud Databases for Enforcing Numeric Invariants," 2015 IEEE 34th Symposium on Reliable Distributed Systems (SRDS), Montreal, QC, 2015, pp. 31-36, doi: 10.1109/SRDS.2015.32.
Its JSON serialization respects the following schema:
{
"type": "BCounter",
"metadata": {
"increment": [
({ClientUId.toJson()}, [
(( ClientUId.toJson(), {
"first": $value, // $value is an integer
"second": Timestamp.toJson()
}, )*( ClientUId.toJson(), {
"first": $value, // $value is an integer
"second": Timestamp.toJson()
} ))?
])?
],
"decrement": [
({ ClientUId.toJson(), {
"first": $value, // $value is an integer
"second": Timestamp.toJson()
}, )*( ClientUId.toJson(), {
"first": $value, // $value is an integer
"second": Timestamp.toJson()
} })?
]
},
"value": $value // $value is an integer
}