From 8956b27b29637a452d0603658f9646b324d904ed Mon Sep 17 00:00:00 2001 From: Aviral Goel Date: Sat, 17 Dec 2016 16:31:29 -0500 Subject: Added specification of counters, moved images to resources --- .../python/operation-based-increment-only-counter.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 chapter/6/resources/code/counters/python/operation-based-increment-only-counter.py (limited to 'chapter/6/resources/code/counters/python/operation-based-increment-only-counter.py') 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) -- cgit v1.2.3