Skip to content

Commit

Permalink
Remove useless GET_TRANSACTION_POOL_BACKLOG endpoint
Browse files Browse the repository at this point in the history
Not only is this endpoint not used anywhere, but it returns (invalid)
cancerous json output when invoked in current stable oxend:

    {
      "jsonrpc": "2.0",
      "id": "0",
      "result": {
        "backlog": "l\u0007\u0000\u0000\u0000\u0000\u0000\u0000�\u001f�\u0000\u0000\u0000\u0000\u0000Y�������",
        "status": "OK",
        "untrusted": false
      }
    }

where that cancer in the backlog field is the raw bytes copied out from
under a struct with 3 uint64_t's.  (It's also invalid json because those
unprintable characters are \xff, which isn't valid UTF-8 encoding, and
thus isn't valid JSON).

Just nuke the whole thing since nothing uses it (probably because it is
such cancer).
  • Loading branch information
jagerman committed Aug 19, 2021
1 parent 425a22f commit c5d33d5
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 60 deletions.
12 changes: 0 additions & 12 deletions src/cryptonote_core/tx_pool.cpp
Expand Up @@ -1163,18 +1163,6 @@ namespace cryptonote
}, false, include_unrelayed_txes);
}
//------------------------------------------------------------------
void tx_memory_pool::get_transaction_backlog(std::vector<rpc::tx_backlog_entry>& backlog, bool include_unrelayed_txes) const
{
auto locks = tools::unique_locks(m_transactions_lock, m_blockchain);

const uint64_t now = time(NULL);
backlog.reserve(m_blockchain.get_txpool_tx_count(include_unrelayed_txes));
m_blockchain.for_all_txpool_txes([&backlog, now](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata *bd){
backlog.push_back({meta.weight, meta.fee, meta.receive_time - now});
return true;
}, false, include_unrelayed_txes);
}
//------------------------------------------------------------------
tx_memory_pool::tx_stats tx_memory_pool::get_transaction_stats(bool include_unrelayed_txes) const
{
auto locks = tools::unique_locks(m_transactions_lock, m_blockchain);
Expand Down
10 changes: 0 additions & 10 deletions src/cryptonote_core/tx_pool.h
Expand Up @@ -43,7 +43,6 @@
#include "cryptonote_basic/verification_context.h"
#include "blockchain_db/blockchain_db.h"
#include "crypto/hash.h"
#include "rpc/core_rpc_server_commands_defs.h"
#include "tx_blink.h"
#include "oxen_economy.h"

Expand Down Expand Up @@ -410,15 +409,6 @@ namespace cryptonote
*/
void get_transaction_hashes(std::vector<crypto::hash>& txs, bool include_unrelayed_txes = true, bool include_only_blinked = false) const;

/**
* @brief get (weight, fee, receive time) for all transaction in the pool
*
* @param txs return-by-reference that data
* @param include_unrelayed_txes include unrelayed txes in the result
*
*/
void get_transaction_backlog(std::vector<rpc::tx_backlog_entry>& backlog, bool include_unrelayed_txes = true) const;

/// Return type of get_transaction_stats()
struct tx_stats
{
Expand Down
13 changes: 0 additions & 13 deletions src/rpc/core_rpc_server.cpp
Expand Up @@ -2641,19 +2641,6 @@ namespace cryptonote::rpc {

sync.response["status"] = STATUS_OK;
}
//------------------------------------------------------------------------------------------------------------------------------
void core_rpc_server::invoke(GET_TRANSACTION_POOL_BACKLOG& get_transaction_pool_backlog, rpc_context context)
{
PERF_TIMER(on_get_txpool_backlog);
//TODO handle bootstrap daemon
//if (use_bootstrap_daemon_if_necessary<GET_TRANSACTION_POOL_BACKLOG>(req, res))
//return res;

std::vector<rpc::tx_backlog_entry> backlog;
m_core.get_pool().get_transaction_backlog(backlog);
get_transaction_pool_backlog.response["backlog"] = json::parse(backlog.begin(), backlog.end());
get_transaction_pool_backlog.response["status"] = STATUS_OK;
}

namespace {
output_distribution_data process_distribution(
Expand Down
1 change: 0 additions & 1 deletion src/rpc/core_rpc_server.h
Expand Up @@ -217,7 +217,6 @@ namespace cryptonote::rpc {
void invoke(GETBLOCKCOUNT& getblockcount, rpc_context context);
void invoke(MINING_STATUS& mining_status, rpc_context context);
void invoke(GET_TRANSACTION_POOL_HASHES& get_transaction_pool_hashes, rpc_context context);
void invoke(GET_TRANSACTION_POOL_BACKLOG& get_transaction_pool_backlog, rpc_context context);
void invoke(GET_TRANSACTION_POOL_STATS& get_transaction_pool_stats, rpc_context context);
void invoke(GET_TRANSACTIONS& req, rpc_context context);
void invoke(GET_CONNECTIONS& get_connections, rpc_context context);
Expand Down
24 changes: 0 additions & 24 deletions src/rpc/core_rpc_server_commands_defs.h
Expand Up @@ -1278,29 +1278,6 @@ namespace cryptonote::rpc {
static constexpr auto names() { return NAMES("get_transaction_pool_hashes"); }
};

OXEN_RPC_DOC_INTROSPECT
struct tx_backlog_entry
{
uint64_t weight; //
uint64_t fee; // Fee in Loki measured in atomic units.
uint64_t time_in_pool;
};

//-----------------------------------------------
/// Get all transaction pool backlog.
///
/// Inputs: none
///
/// Output values available from a public RPC endpoint:
///
/// - \p status General RPC status string. `"OK"` means everything looks good.
/// - \p backlog Array of structures tx_backlog_entry (in binary form):
/// - \p untrusted States if the result is obtained using the bootstrap mode, and is therefore not trusted (`true`), or when the daemon is fully synced (`false`).
struct GET_TRANSACTION_POOL_BACKLOG : PUBLIC, NO_ARGS
{
static constexpr auto names() { return NAMES("get_txpool_backlog"); }
};

//-----------------------------------------------
/// Get the transaction pool statistics.
///
Expand Down Expand Up @@ -2733,7 +2710,6 @@ namespace cryptonote::rpc {
GETBLOCKCOUNT,
MINING_STATUS,
GET_TRANSACTION_POOL_HASHES,
GET_TRANSACTION_POOL_BACKLOG,
GET_TRANSACTION_POOL_STATS,
GET_TRANSACTIONS,
GET_SERVICE_NODES,
Expand Down

0 comments on commit c5d33d5

Please sign in to comment.