diff options
| author | Aviral Goel <goel.aviral@gmail.com> | 2016-12-17 16:31:29 -0500 |
|---|---|---|
| committer | Aviral Goel <goel.aviral@gmail.com> | 2016-12-17 16:31:29 -0500 |
| commit | 8956b27b29637a452d0603658f9646b324d904ed (patch) | |
| tree | 9df59595ff6712c1056a193df8d37a47aab8a475 /chapter/6/resources/code/counters/python/operation-based-increment-only-counter.py | |
| parent | bd0ca41936a724619e31d6930b554bc12697768d (diff) | |
Added specification of counters, moved images to resources
Diffstat (limited to 'chapter/6/resources/code/counters/python/operation-based-increment-only-counter.py')
| -rw-r--r-- | chapter/6/resources/code/counters/python/operation-based-increment-only-counter.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/chapter/6/resources/code/counters/python/operation-based-increment-only-counter.py b/chapter/6/resources/code/counters/python/operation-based-increment-only-counter.py new file mode 100644 index 0000000..b10cd98 --- /dev/null +++ b/chapter/6/resources/code/counters/python/operation-based-increment-only-counter.py @@ -0,0 +1,15 @@ +class CmRDT: + pass + +class Counter(CmRDT): + + def __init__(self): # constructor function + self._count = 0 + + def value(self): # query function + return self._count + + def increment(self): # update function + self._count += 1 + for replica in self.replicas(): + self.transmit("increment", replica) |
