Add external session to tx obsolete method
This commit is contained in:
parent
e29bc6fa8c
commit
449a748b82
@ -301,8 +301,9 @@ def get_state_log(chain_spec, tx_hash, session=None):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def cancel_obsoletes_by_cache(chain_spec, tx_hash):
|
def obsolete_by_cache(chain_spec, tx_hash, final, session=None):
|
||||||
session = SessionBase.create_session()
|
session = SessionBase.bind_session(session)
|
||||||
|
|
||||||
q = session.query(
|
q = session.query(
|
||||||
Otx.nonce.label('nonce'),
|
Otx.nonce.label('nonce'),
|
||||||
TxCache.sender.label('sender'),
|
TxCache.sender.label('sender'),
|
||||||
@ -324,7 +325,8 @@ def cancel_obsoletes_by_cache(chain_spec, tx_hash):
|
|||||||
|
|
||||||
for otwo in q.all():
|
for otwo in q.all():
|
||||||
try:
|
try:
|
||||||
otwo.cancel(True, session=session)
|
otwo.cancel(final, session=session)
|
||||||
|
logg.debug('cancel {} final {}'.format(tx_hash, final))
|
||||||
except TxStateChangeError as e:
|
except TxStateChangeError as e:
|
||||||
logg.exception('cancel non-final fail: {}'.format(e))
|
logg.exception('cancel non-final fail: {}'.format(e))
|
||||||
session.close()
|
session.close()
|
||||||
@ -334,6 +336,7 @@ def cancel_obsoletes_by_cache(chain_spec, tx_hash):
|
|||||||
session.close()
|
session.close()
|
||||||
raise(e)
|
raise(e)
|
||||||
session.commit()
|
session.commit()
|
||||||
session.close()
|
|
||||||
|
SessionBase.release_session(session)
|
||||||
|
|
||||||
return tx_hash
|
return tx_hash
|
||||||
|
Loading…
Reference in New Issue
Block a user