forked from Qortal/qortal
Transaction.importAsUnconfirmed() now BLOCKS for blockchain lock, instead of non-blocking try()
This is a serious change as it affects many callers. Controller.onNetworkTransactionMessager() -- should be OK to block as it's only one EPC thread TransactionsResource.processTransaction() -- should be OK to block as it's only one Jetty thread AND has its own 30s timeout wrapper anyway Implementations of AcctTradeBot.progress() e.g. BitcoinACCTv1TradeBot.progress() & LitecoinACCTv1TradeBot.progress() TradeBot.updatePresence() -- these are called via BlockMinter/Synchronizer when blockchain lock is already held, so will are unaffected AcctTradeBot.createTrade() and AcctTradeBot.startResponse() -- these are called via API and previously would only perform non-blocking blockchainLock.try() but now perform blocking blockchainLock.lock() thus preventing NO_BLOCKCHAIN_LOCK when creating/responding to trades especially after a (wasted) MESSAGE PoW compute but with potential downside that API response might be delayed e.g. by a very slow sync round Future work could look into removing the need for blockchain lock when calling Transaction.importAsUnconfirmed().
This commit is contained in:
parent
78f62751e5
commit
918a331609
@ -765,7 +765,7 @@ public abstract class Transaction {
|
||||
/**
|
||||
* Import into our repository as a new, unconfirmed transaction.
|
||||
* <p>
|
||||
* @implSpec <i>tries</i> to obtain blockchain lock
|
||||
* @implSpec <i>blocks</i> to obtain blockchain lock
|
||||
* <p>
|
||||
* If transaction is valid, then:
|
||||
* <ul>
|
||||
@ -778,8 +778,7 @@ public abstract class Transaction {
|
||||
public ValidationResult importAsUnconfirmed() throws DataException {
|
||||
// Attempt to acquire blockchain lock
|
||||
ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock();
|
||||
if (!blockchainLock.tryLock())
|
||||
return ValidationResult.NO_BLOCKCHAIN_LOCK;
|
||||
blockchainLock.lock();
|
||||
|
||||
try {
|
||||
// Check transaction doesn't already exist
|
||||
|
Loading…
Reference in New Issue
Block a user