I have read some articles about CRDT. And knew the G-Counter is an implementation of CvRDT. It can only do increasing operations. However, each node in the algorithm has its own slot. If it is transformed to CmRDT and every node broadcasts its operation instead of the whole state, can the G-Counter do decrements? Why or why not?
Asked
Active
Viewed 190 times
1 Answers
0
G-Counter name comes from grow-only counter. It's defined by its semantics, which is not specific to either CvRDT or CmRDT. So nothing stands against building an operation-based counter with increment/decrement operations, the thing is, it won't be just a G-Counter anymore ;)

Bartosz Sypytkowski
- 7,463
- 19
- 36
-
If G-Counter can be modified to count with increment/decrement operations (maybe named as Some-Counter), why we need double space (two G-Counter), not one, to build a PN-Counter? – IvanaGyro Apr 27 '19 at 07:34
-
1Semantics of G-Counter define only increment operation (hence the name grow-only counter), while PN-Counter has both increment/decrement operations (to make positive-negative counting possible). That's all, when it comes to semantics. Now the implementation: state-based PN-Counter is usually implemented from two G-Counters to maintain convergence property of merge method. However nothing requires operation-based counter to use the same implementation. In fact, most commutative counters are implemented as simple values. Semantics of Cv- and CmRDTs may be the same, but the implementations differ – Bartosz Sypytkowski Apr 27 '19 at 16:20