commit f8b256b51b754e4abf55321e5465c245743c513c
parent 1f7ca2864771e569a0ae6bb485e8f6477f912442
Author: lash <dev@holbrook.no>
Date: Mon, 14 Mar 2022 19:53:54 +0000
Add reserve, send enclosure
Diffstat:
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/chainqueue/entry.py b/chainqueue/entry.py
@@ -27,6 +27,10 @@ class QueueEntry:
self.synced = False
+ def serialize(self):
+ return self.signed_tx
+
+
def create(self, signed_tx):
signed_tx = normalize_hex(signed_tx)
self.k = self.store.put(self.tx_hash, signed_tx)
diff --git a/chainqueue/state.py b/chainqueue/state.py
@@ -46,7 +46,7 @@ class Verify:
return 'already finalized'
if from_state & state_store.IN_NETWORK:
return 'already in network'
- if from_state & state_store.RESERVED:
+ if not from_state & state_store.RESERVED:
return 'not reserved'
if from_state & state_store.mask_error:
return 'already in error state'
diff --git a/chainqueue/store/base.py b/chainqueue/store/base.py
@@ -100,6 +100,12 @@ class Store:
return self.by_state(state=0, limit=limit, strict=True)
+ def reserve(self, k):
+ entry = QueueEntry(self, k)
+ entry.load()
+ entry.reserve()
+
+
def enqueue(self, k):
entry = QueueEntry(self, k)
entry.load()
@@ -113,3 +119,16 @@ class Store:
entry = QueueEntry(self, k)
entry.load()
entry.sendfail()
+
+
+ def send_start(self, k):
+ entry = QueueEntry(self, k)
+ entry.load()
+ entry.reserve()
+ return entry
+
+
+ def send_end(self, k):
+ entry = QueueEntry(self, k)
+ entry.load()
+ entry.sent()