chainqueue

Blockchain transaction queue control
Log | Files | Refs | LICENSE

commit 18a4d65784caa7826761a6a8a85d2300c1150522
parent 11568ee2bac52d7f26259274ce8a23dba4efa803
Author: nolash <dev@holbrook.no>
Date:   Sun,  2 May 2021 18:09:37 +0200

Update url

Diffstat:
Achainqueue/db/migrations/sqlalchemy.py | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mchainqueue/db/models/otx.py | 8++++----
Msetup.cfg | 4++--
3 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/chainqueue/db/migrations/sqlalchemy.py b/chainqueue/db/migrations/sqlalchemy.py @@ -0,0 +1,55 @@ +from alembic import op +import sqlalchemy as sa + +def chainqueue_upgrade(major, minor, patch): + r0_0_1_u() + + +def chainqueue_downgrade(major, minor, patch): + r0_0_1_d() + + +def r0_0_1_u(): + op.create_table( + 'otx', + sa.Column('id', sa.Integer, primary_key=True), + sa.Column('date_created', sa.DateTime, nullable=False), + sa.Column('date_updated', sa.DateTime, nullable=False), + sa.Column('nonce', sa.Integer, nullable=False), + sa.Column('tx_hash', sa.Text, nullable=False), + sa.Column('signed_tx', sa.Text, nullable=False), + sa.Column('status', sa.Integer, nullable=False, default=0), + sa.Column('block', sa.Integer), + ) + op.create_index('idx_otx_tx', 'otx', ['tx_hash'], unique=True) + + op.create_table( + 'otx_state_log', + sa.Column('id', sa.Integer, primary_key=True), + sa.Column('otx_id', sa.Integer, sa.ForeignKey('otx.id'), nullable=False), + sa.Column('date', sa.DateTime, nullable=False), + sa.Column('status', sa.Integer, nullable=False), + ) + + op.create_table( + 'tx_cache', + sa.Column('id', sa.Integer, primary_key=True), + sa.Column('otx_id', sa.Integer, sa.ForeignKey('otx.id'), nullable=True), + sa.Column('date_created', sa.DateTime, nullable=False), + sa.Column('date_updated', sa.DateTime, nullable=False), + sa.Column('date_checked', sa.DateTime, nullable=False), + sa.Column('source_token_address', sa.String(42), nullable=False), + sa.Column('destination_token_address', sa.String(42), nullable=False), + sa.Column('sender', sa.String(42), nullable=False), + sa.Column('recipient', sa.String(42), nullable=False), + sa.Column('from_value', sa.NUMERIC(), nullable=False), + sa.Column('to_value', sa.NUMERIC(), nullable=True), + sa.Column('tx_index', sa.Integer, nullable=True), + ) + + +def r0_0_1_d(): + op.drop_table('tx_cache') + op.drop_table('otx_state_log') + op.drop_index('idx_otx_tx') + op.drop_table('otx') diff --git a/chainqueue/db/models/otx.py b/chainqueue/db/models/otx.py @@ -460,11 +460,11 @@ class Otx(SessionBase): if confirmed: status = self.status - if self.status > 0 and self.status & (StatusBits.OBSOLETE & StatusBits.IN_NETWORK) == 0: + if self.status > 0 and self.status & (StatusBits.OBSOLETE | StatusBits.IN_NETWORK) == 0: SessionBase.release_session(session) - raise TxStateChangeError('CANCEL can only be set on an entry marked OBSOLETE ({})'.format(status)) - self.__set_status(StatusEnum.FINAL, session) - self.__set_status(StatusEnum.OBSOLETED, session) + raise TxStateChangeError('CANCEL can only be set on an entry marked OBSOLETE or IN_NETWORK ({})'.format(status)) + self.__set_status(StatusBits.FINAL, session) + self.__set_status(StatusBits.OBSOLETE, session) self.__reset_status(StatusBits.RESERVED | StatusBits.QUEUED, session) diff --git a/setup.cfg b/setup.cfg @@ -1,10 +1,10 @@ [metadata] name = chainqueue -version = 0.0.2a1 +version = 0.0.2a2 description = Generic blockchain transaction queue control author = Louis Holbrook author_email = dev@holbrook.no -url = https://gitlab.com/nolash/chainlib +url = https://gitlab.com/chaintools/chainqueue keywords = cic cryptocurrency