Compare commits

..

No commits in common. "c22fafad5351843d9c750d07463ebc24ff96c5a5" and "0fa12adfa1ddccc183edbb9307757f15109e0672" have entirely different histories.

6 changed files with 10 additions and 43 deletions

View File

@ -115,8 +115,7 @@ class QueueEntry:
def fail(self, block, tx): def fail(self, block, tx):
if self.__match_state(self.store.NETWORK_ERROR): if self.__match_state(self.store.NETWORK_ERROR):
return return
v = self.store.state(self.k) self.store.set(self.k, self.store.NETWORK_ERROR)
self.store.change(self.k, v | self.store.NETWORK_ERROR, self.store.QUEUED)
if self.store.cache: if self.store.cache:
self.store.cache.set_block(self.tx_hash, block, tx) self.store.cache.set_block(self.tx_hash, block, tx)

View File

@ -1,14 +1,10 @@
# standard imports # standard imports
import re import re
import datetime import datetime
import logging
# local imports # local imports
from chainqueue.cache import CacheTx from chainqueue.cache import CacheTx
from chainqueue.entry import QueueEntry from chainqueue.entry import QueueEntry
from chainqueue.error import NotLocalTxError
logg = logging.getLogger(__name__)
def to_key(t, n, k): def to_key(t, n, k):
@ -43,7 +39,6 @@ class Store:
'modified', 'modified',
]: ]:
setattr(self, v, getattr(self.state_store, v)) setattr(self, v, getattr(self.state_store, v))
self.state_store.sync()
def put(self, v, cache_adapter=CacheTx): def put(self, v, cache_adapter=CacheTx):
@ -61,10 +56,7 @@ class Store:
def get(self, k): def get(self, k):
try:
s = self.index_store.get(k) s = self.index_store.get(k)
except FileNotFoundError:
raise NotLocalTxError(k)
v = self.state_store.get(s) v = self.state_store.get(s)
return (s, v,) return (s, v,)

View File

@ -4,7 +4,7 @@ version = 0.1.0
description = Generic blockchain transaction queue control description = Generic blockchain transaction queue control
author = Louis Holbrook author = Louis Holbrook
author_email = dev@holbrook.no author_email = dev@holbrook.no
url = https://gitlab.com/chaintool/chainqueue url = https://gitlab.com/chaintools/chainqueue
keywords = keywords =
cic cic
cryptocurrency cryptocurrency
@ -29,11 +29,13 @@ python_requires = >= 3.6
include_package_data = True include_package_data = True
packages = packages =
chainqueue chainqueue
chainqueue.cache chainqueue.db
chainqueue.db.models
chainqueue.sql
chainqueue.adapters
chainqueue.unittest chainqueue.unittest
chainqueue.store
chainqueue.runnable chainqueue.runnable
#[options.entry_points] [options.entry_points]
#console_scripts = console_scripts =
# chainqueue-list = chainqueue.runnable.list:main chainqueue-list = chainqueue.runnable.list:main

View File

@ -2,7 +2,6 @@
import tempfile import tempfile
import unittest import unittest
import shutil import shutil
import logging
# external imports # external imports
from shep.store.file import SimpleFileStoreFactory from shep.store.file import SimpleFileStoreFactory
@ -20,7 +19,6 @@ from tests.common import (
MockContentStore, MockContentStore,
) )
logg = logging.getLogger(__name__)
class TestShepBase(unittest.TestCase): class TestShepBase(unittest.TestCase):
@ -32,7 +30,6 @@ class TestShepBase(unittest.TestCase):
counter = MockCounter() counter = MockCounter()
chain_spec = ChainSpec('foo', 'bar', 42, 'baz') chain_spec = ChainSpec('foo', 'bar', 42, 'baz')
self.store = Store(chain_spec, self.state, content_store, counter) self.store = Store(chain_spec, self.state, content_store, counter)
logg.debug('using path {}'.format(self.path))
def tearDown(self): def tearDown(self):

View File

@ -5,8 +5,6 @@ import unittest
# external imports # external imports
from hexathon import add_0x from hexathon import add_0x
from chainlib.tx import Tx
from chainlib.block import Block
# local imports # local imports
from chainqueue import QueueEntry from chainqueue import QueueEntry
@ -61,25 +59,5 @@ class TestEntry(TestShepBase):
self.assertEqual(len(txs), 1) self.assertEqual(len(txs), 1)
def test_entry_change(self):
signed_tx = add_0x(os.urandom(128).hex())
nonce = 42
entry = QueueEntry(self.store, cache_adapter=MockCacheTokenTx)
tx_hash = entry.create(signed_tx)
block = Block()
block.number = 13
tx = Tx(None)
tx.index = 666
entry.readysend()
entry.reserve()
entry.sendfail()
entry = QueueEntry(self.store, tx_hash, cache_adapter=MockCacheTokenTx)
entry.load()
self.assertEqual(str(entry), tx_hash + ': SENDFAIL')
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -55,6 +55,5 @@ class TestShep(TestShepBase):
self.store.put('bar', cache_adapter=MockCacheTokenTx) self.store.put('bar', cache_adapter=MockCacheTokenTx)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()