2021-04-02 18:45:51 +02:00
|
|
|
# external imports
|
|
|
|
from chainlib.chain import ChainSpec
|
|
|
|
import chainqueue.state
|
|
|
|
|
|
|
|
# local imports
|
2021-04-02 23:26:13 +02:00
|
|
|
import celery
|
2021-04-02 18:45:51 +02:00
|
|
|
from cic_eth.task import CriticalSQLAlchemyTask
|
2021-04-02 23:26:13 +02:00
|
|
|
from cic_eth.db.models.base import SessionBase
|
|
|
|
|
|
|
|
celery_app = celery.current_app
|
2021-04-02 18:45:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
2021-04-04 13:27:28 +02:00
|
|
|
def set_sent(chain_spec_dict, tx_hash, fail=False):
|
2021-04-02 18:45:51 +02:00
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
2021-04-02 23:26:13 +02:00
|
|
|
session = SessionBase.create_session()
|
2021-04-04 13:27:28 +02:00
|
|
|
r = chainqueue.state.set_sent(chain_spec, tx_hash, fail, session=session)
|
2021-04-02 23:26:13 +02:00
|
|
|
session.close()
|
|
|
|
return r
|
2021-04-02 18:45:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
2021-04-04 13:27:28 +02:00
|
|
|
def set_final(chain_spec_dict, tx_hash, block=None, fail=False):
|
2021-04-02 18:45:51 +02:00
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
2021-04-02 23:26:13 +02:00
|
|
|
session = SessionBase.create_session()
|
2021-04-04 13:27:28 +02:00
|
|
|
r = chainqueue.state.set_final(chain_spec, tx_hash, block, fail, session=session)
|
2021-04-02 23:26:13 +02:00
|
|
|
session.close()
|
|
|
|
return r
|
2021-04-02 18:45:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
|
|
|
def set_cancel(chain_spec_dict, tx_hash, manual=False):
|
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
2021-04-02 23:26:13 +02:00
|
|
|
session = SessionBase.create_session()
|
|
|
|
r = chainqueue.state.set_cancel(chain_spec, tx_hash, manual, session=session)
|
|
|
|
session.close()
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
2021-04-02 18:45:51 +02:00
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
|
|
|
def set_rejected(chain_spec_dict, tx_hash):
|
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
2021-04-02 23:26:13 +02:00
|
|
|
session = SessionBase.create_session()
|
|
|
|
r = chainqueue.state.set_rejected(chain_spec, tx_hash, session=session)
|
|
|
|
session.close()
|
|
|
|
return r
|
2021-04-02 18:45:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
|
|
|
def set_fubar(chain_spec_dict, tx_hash):
|
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
2021-04-02 23:26:13 +02:00
|
|
|
session = SessionBase.create_session()
|
|
|
|
r = chainqueue.state.set_fubar(chain_spec, tx_hash, session=session)
|
|
|
|
session.close()
|
|
|
|
return r
|
2021-04-02 18:45:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
|
|
|
def set_manual(chain_spec_dict, tx_hash):
|
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
2021-04-02 23:26:13 +02:00
|
|
|
session = SessionBase.create_session()
|
|
|
|
r = chainqueue.state.set_manual(chain_spec, tx_hash, session=session)
|
|
|
|
session.close()
|
|
|
|
return r
|
|
|
|
|
2021-04-02 18:45:51 +02:00
|
|
|
|
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
|
|
|
def set_ready(chain_spec_dict, tx_hash):
|
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
2021-04-02 23:26:13 +02:00
|
|
|
session = SessionBase.create_session()
|
|
|
|
r = chainqueue.state.set_ready(chain_spec, tx_hash, session=session)
|
|
|
|
session.close()
|
|
|
|
return r
|
|
|
|
|
2021-04-02 18:45:51 +02:00
|
|
|
|
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
|
|
|
def set_reserved(chain_spec_dict, tx_hash):
|
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
2021-04-02 23:26:13 +02:00
|
|
|
session = SessionBase.create_session()
|
|
|
|
r = chainqueue.state.set_reserved(chain_spec, tx_hash, session=session)
|
|
|
|
session.close()
|
|
|
|
return r
|
|
|
|
|
2021-04-02 18:45:51 +02:00
|
|
|
|
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
|
|
|
def set_waitforgas(chain_spec_dict, tx_hash):
|
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
2021-04-02 23:26:13 +02:00
|
|
|
session = SessionBase.create_session()
|
|
|
|
r = chainqueue.state.set_waitforgas(chain_spec, tx_hash, session=session)
|
|
|
|
session.close()
|
|
|
|
return r
|
2021-04-02 18:45:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
|
|
|
def get_state_log(chain_spec_dict, tx_hash):
|
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
2021-04-02 23:26:13 +02:00
|
|
|
session = SessionBase.create_session()
|
|
|
|
r = chainqueue.state.get_state_log(chain_spec, tx_hash, session=session)
|
|
|
|
session.close()
|
|
|
|
return r
|
2021-04-05 12:21:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
@celery_app.task(base=CriticalSQLAlchemyTask)
|
|
|
|
def obsolete(chain_spec_dict, tx_hash, final):
|
|
|
|
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
|
|
|
session = SessionBase.create_session()
|
|
|
|
r = chainqueue.state.obsolete_by_cache(chain_spec, tx_hash, final, session=session)
|
|
|
|
session.close()
|
|
|
|
return r
|