Compare commits

...

4 Commits

Author SHA1 Message Date
lash
6c360ca2e5 Add reserved check method 2022-04-29 06:28:01 +00:00
lash
ff74679de8 Remove unneeded deps 2022-04-28 15:37:06 +00:00
lash
94bd5c8cdf Add cli handling and settings 2022-04-28 12:37:08 +00:00
lash
ccbbcc2157 Sync chainqueue state store on get 2022-04-27 06:23:58 +00:00
9 changed files with 51 additions and 17 deletions

View File

@@ -0,0 +1,11 @@
# standard imports
import os
# local imports
from .arg import process_flags
from .config import process_config
__script_dir = os.path.dirname(os.path.realpath(__file__))
data_dir = os.path.join(os.path.dirname(__script_dir), 'data')
config_dir = os.path.join(data_dir, 'config')

2
chainqueue/cli/arg.py Normal file
View File

@@ -0,0 +1,2 @@
def process_flags(argparser, flags):
argparser.add_argument('--backend', type=str, help='Backend to use for state store')

8
chainqueue/cli/config.py Normal file
View File

@@ -0,0 +1,8 @@
def process_config(config, args, flags):
args_override = {}
args_override['QUEUE_BACKEND'] = getattr(args, 'backend')
config.dict_override(args_override, 'local cli args')
return config

View File

@@ -1,9 +1,2 @@
[database] [queue]
name = backend = mem
engine =
driver =
host =
port =
user =
password =
debug = 0

View File

@@ -134,6 +134,10 @@ class QueueEntry:
self.store.cache.set_block(self.tx_hash, block, tx) self.store.cache.set_block(self.tx_hash, block, tx)
def test(self, state):
return self.__match_state(state)
def __str__(self): def __str__(self):
v = self.store.get(self.tx_hash) v = self.store.get(self.tx_hash)
n = self.store.state(v[0]) n = self.store.state(v[0])

8
chainqueue/settings.py Normal file
View File

@@ -0,0 +1,8 @@
# external imports
from chainlib.settings import ChainSettings
class ChainqueueSettings(ChainSettings):
def process_queue_backend(self, config):
self.o['QUEUE_BACKEND'] = config.get('QUEUE_BACKEND')

View File

@@ -67,6 +67,7 @@ class Store:
s = self.index_store.get(k) s = self.index_store.get(k)
except FileNotFoundError: except FileNotFoundError:
raise NotLocalTxError(k) raise NotLocalTxError(k)
self.state_store.sync()
v = self.state_store.get(s) v = self.state_store.get(s)
return (s, v,) return (s, v,)
@@ -152,3 +153,9 @@ class Store:
entry = QueueEntry(self, k) entry = QueueEntry(self, k)
entry.load() entry.load()
entry.sent() entry.sent()
def is_reserved(self, k):
entry = QueueEntry(self, k)
entry.load()
return entry.test(self.RESERVED)

View File

@@ -1,9 +1,9 @@
pysha3==1.0.2 #pysha3==1.0.2
hexathon~=0.1.5 hexathon~=0.1.5
leveldir~=0.3.0 leveldir~=0.3.0
alembic==1.4.2 #alembic==1.4.2
SQLAlchemy==1.3.20 #SQLAlchemy==1.3.20
confini~=0.6.0 confini~=0.6.0
pyxdg~=0.27 #pyxdg~=0.27
chainlib>=0.1.0b1,<=0.1.0 chainlib~=0.1.1
shep>=0.1.1rc1,<=0.3.0 shep~=0.2.3

View File

@@ -1,6 +1,6 @@
[metadata] [metadata]
name = chainqueue name = chainqueue
version = 0.1.2 version = 0.1.5
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
@@ -25,7 +25,7 @@ licence_files =
LICENSE.txt LICENSE.txt
[options] [options]
python_requires = >= 3.6 python_requires = >= 3.7
include_package_data = True include_package_data = True
packages = packages =
chainqueue chainqueue
@@ -33,6 +33,7 @@ packages =
chainqueue.unittest chainqueue.unittest
chainqueue.store chainqueue.store
chainqueue.runnable chainqueue.runnable
chainqueue.cli
#[options.entry_points] #[options.entry_points]
#console_scripts = #console_scripts =