Add reserve, send enclosure

This commit is contained in:
lash 2022-03-14 19:53:54 +00:00
parent 1f7ca28647
commit f8b256b51b
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 24 additions and 1 deletions

View File

@ -27,6 +27,10 @@ class QueueEntry:
self.synced = False self.synced = False
def serialize(self):
return self.signed_tx
def create(self, signed_tx): def create(self, signed_tx):
signed_tx = normalize_hex(signed_tx) signed_tx = normalize_hex(signed_tx)
self.k = self.store.put(self.tx_hash, signed_tx) self.k = self.store.put(self.tx_hash, signed_tx)

View File

@ -46,7 +46,7 @@ class Verify:
return 'already finalized' return 'already finalized'
if from_state & state_store.IN_NETWORK: if from_state & state_store.IN_NETWORK:
return 'already in network' return 'already in network'
if from_state & state_store.RESERVED: if not from_state & state_store.RESERVED:
return 'not reserved' return 'not reserved'
if from_state & state_store.mask_error: if from_state & state_store.mask_error:
return 'already in error state' return 'already in error state'

View File

@ -100,6 +100,12 @@ class Store:
return self.by_state(state=0, limit=limit, strict=True) 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): def enqueue(self, k):
entry = QueueEntry(self, k) entry = QueueEntry(self, k)
entry.load() entry.load()
@ -113,3 +119,16 @@ class Store:
entry = QueueEntry(self, k) entry = QueueEntry(self, k)
entry.load() entry.load()
entry.sendfail() 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()