diff --git a/libethcore/Common.h b/libethcore/Common.h index 25a6a8e1d..732d09981 100644 --- a/libethcore/Common.h +++ b/libethcore/Common.h @@ -112,6 +112,7 @@ enum class ImportResult AlreadyInChain, AlreadyKnown, Malformed, + OverbidGasPrice, BadChain }; diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index ad551c2ec..2b0a64491 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -105,7 +105,8 @@ void Client::onBadBlock(Exception& _ex) const bytes const* block = boost::get_error_info(_ex); if (!block) { - cwarn << "ODD: onBadBlock called but exception has no block in it."; + cwarn << "ODD: onBadBlock called but exception (" << _ex.what() << ") has no block in it."; + cwarn << boost::diagnostic_information(_ex, true); return; } diff --git a/libethereum/TransactionQueue.cpp b/libethereum/TransactionQueue.cpp index a86f6abf3..8931ee218 100644 --- a/libethereum/TransactionQueue.cpp +++ b/libethereum/TransactionQueue.cpp @@ -113,6 +113,26 @@ ImportResult TransactionQueue::manageImport_WITH_LOCK(h256 const& _h, Transactio // If it doesn't work, the signature is bad. // The transaction's nonce may yet be invalid (or, it could be "valid" but we may be missing a marginally older transaction). + auto r = m_senders.equal_range(_transaction.from()); + for (auto it = r.first; it != r.second; ++it) + if (m_current.count(it->second) && m_current[it->second].nonce() == _transaction.nonce()) + if (_transaction.gasPrice() < m_current[it->second].gasPrice()) + return ImportResult::OverbidGasPrice; + else + { + remove_WITH_LOCK(it->second); + break; + } + else if (m_future.count(it->second) && m_future[it->second].nonce() == _transaction.nonce()) + if (_transaction.gasPrice() < m_future[it->second].gasPrice()) + return ImportResult::OverbidGasPrice; + else + { + remove_WITH_LOCK(it->second); + break; + } + else {} + // If valid, append to blocks. insertCurrent_WITH_LOCK(make_pair(_h, _transaction)); m_known.insert(_h);