mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-25 19:31:32 +02:00
[prep/rpc] remove entry and expiry time from getorphantxs
Expiry is going away in a later commit. This is only an RPC change. Behavior of the orphanage does not change. Note that getorphantxs is marked experimental.
This commit is contained in:
@@ -37,7 +37,7 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ret = m_orphans.emplace(wtxid, OrphanTx{{tx, {peer}, Now<NodeSeconds>() + ORPHAN_TX_EXPIRE_TIME}, m_orphan_list.size()});
|
||||
auto ret = m_orphans.emplace(wtxid, OrphanTx{{tx, {peer}}, Now<NodeSeconds>() + ORPHAN_TX_EXPIRE_TIME, m_orphan_list.size()});
|
||||
assert(ret.second);
|
||||
m_orphan_list.push_back(ret.first);
|
||||
for (const CTxIn& txin : tx->vin) {
|
||||
@@ -318,7 +318,7 @@ std::vector<TxOrphanage::OrphanTxBase> TxOrphanage::GetOrphanTransactions() cons
|
||||
std::vector<OrphanTxBase> ret;
|
||||
ret.reserve(m_orphans.size());
|
||||
for (auto const& o : m_orphans) {
|
||||
ret.push_back({o.second.tx, o.second.announcers, o.second.nTimeExpire});
|
||||
ret.push_back({o.second.tx, o.second.announcers});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@@ -84,7 +84,6 @@ public:
|
||||
CTransactionRef tx;
|
||||
/** Peers added with AddTx or AddAnnouncer. */
|
||||
std::set<NodeId> announcers;
|
||||
NodeSeconds nTimeExpire;
|
||||
|
||||
/** Get the weight of this transaction, an approximation of its memory usage. */
|
||||
unsigned int GetUsage() const {
|
||||
@@ -112,6 +111,7 @@ public:
|
||||
|
||||
protected:
|
||||
struct OrphanTx : public OrphanTxBase {
|
||||
NodeSeconds nTimeExpire;
|
||||
size_t list_pos;
|
||||
};
|
||||
|
||||
|
@@ -832,8 +832,6 @@ static std::vector<RPCResult> OrphanDescription()
|
||||
RPCResult{RPCResult::Type::NUM, "bytes", "The serialized transaction size in bytes"},
|
||||
RPCResult{RPCResult::Type::NUM, "vsize", "The virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted."},
|
||||
RPCResult{RPCResult::Type::NUM, "weight", "The transaction weight as defined in BIP 141."},
|
||||
RPCResult{RPCResult::Type::NUM_TIME, "entry", "The entry time into the orphanage expressed in " + UNIX_EPOCH_TIME},
|
||||
RPCResult{RPCResult::Type::NUM_TIME, "expiration", "The orphan expiration time expressed in " + UNIX_EPOCH_TIME},
|
||||
RPCResult{RPCResult::Type::ARR, "from", "",
|
||||
{
|
||||
RPCResult{RPCResult::Type::NUM, "peer_id", "Peer ID"},
|
||||
@@ -849,8 +847,6 @@ static UniValue OrphanToJSON(const node::TxOrphanage::OrphanTxBase& orphan)
|
||||
o.pushKV("bytes", orphan.tx->GetTotalSize());
|
||||
o.pushKV("vsize", GetVirtualTransactionSize(*orphan.tx));
|
||||
o.pushKV("weight", GetTransactionWeight(*orphan.tx));
|
||||
o.pushKV("entry", int64_t{TicksSinceEpoch<std::chrono::seconds>(orphan.nTimeExpire - node::ORPHAN_TX_EXPIRE_TIME)});
|
||||
o.pushKV("expiration", int64_t{TicksSinceEpoch<std::chrono::seconds>(orphan.nTimeExpire)});
|
||||
UniValue from(UniValue::VARR);
|
||||
for (const auto fromPeer: orphan.announcers) {
|
||||
from.push_back(fromPeer);
|
||||
|
@@ -4,10 +4,7 @@
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Tests for orphan related RPCs."""
|
||||
|
||||
import time
|
||||
|
||||
from test_framework.mempool_util import (
|
||||
ORPHAN_TX_EXPIRE_TIME,
|
||||
tx_in_orphanage,
|
||||
)
|
||||
from test_framework.messages import (
|
||||
@@ -101,8 +98,6 @@ class OrphanRPCsTest(BitcoinTestFramework):
|
||||
tx_child_2 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_2["new_utxo"])
|
||||
peer_1 = node.add_p2p_connection(P2PInterface())
|
||||
peer_2 = node.add_p2p_connection(P2PInterface())
|
||||
entry_time = int(time.time())
|
||||
node.setmocktime(entry_time)
|
||||
peer_1.send_and_ping(msg_tx(tx_child_1["tx"]))
|
||||
peer_2.send_and_ping(msg_tx(tx_child_2["tx"]))
|
||||
|
||||
@@ -128,9 +123,6 @@ class OrphanRPCsTest(BitcoinTestFramework):
|
||||
assert_equal(len(node.getorphantxs()), 1)
|
||||
orphan_1 = orphanage[0]
|
||||
self.orphan_details_match(orphan_1, tx_child_1, verbosity=1)
|
||||
self.log.info("Checking orphan entry/expiration times")
|
||||
assert_equal(orphan_1["entry"], entry_time)
|
||||
assert_equal(orphan_1["expiration"], entry_time + ORPHAN_TX_EXPIRE_TIME)
|
||||
|
||||
self.log.info("Checking orphan details (verbosity 2)")
|
||||
orphanage = node.getorphantxs(verbosity=2)
|
||||
|
@@ -19,8 +19,6 @@ from .wallet import (
|
||||
MiniWallet,
|
||||
)
|
||||
|
||||
ORPHAN_TX_EXPIRE_TIME = 1200
|
||||
|
||||
def assert_mempool_contents(test_framework, node, expected=None, sync=True):
|
||||
"""Assert that all transactions in expected are in the mempool,
|
||||
and no additional ones exist. 'expected' is an array of
|
||||
|
Reference in New Issue
Block a user