Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <net_processing.h> | #include <net_processing.h> | ||||
#include <addrman.h> | #include <addrman.h> | ||||
#include <avalanche/avalanche.h> | #include <avalanche/avalanche.h> | ||||
#include <avalanche/peermanager.h> | |||||
#include <avalanche/processor.h> | #include <avalanche/processor.h> | ||||
#include <avalanche/proof.h> | #include <avalanche/proof.h> | ||||
#include <avalanche/validation.h> | #include <avalanche/validation.h> | ||||
#include <banman.h> | #include <banman.h> | ||||
#include <blockdb.h> | #include <blockdb.h> | ||||
#include <blockencodings.h> | #include <blockencodings.h> | ||||
#include <blockfilter.h> | #include <blockfilter.h> | ||||
#include <blockvalidity.h> | #include <blockvalidity.h> | ||||
▲ Show 20 Lines • Show All 1,073 Lines • ▼ Show 20 Lines | for (const TxId &txid : unbroadcast_txids) { | ||||
if (m_mempool.exists(txid)) { | if (m_mempool.exists(txid)) { | ||||
RelayTransaction(txid, m_connman); | RelayTransaction(txid, m_connman); | ||||
} else { | } else { | ||||
m_mempool.RemoveUnbroadcastTx(txid, true); | m_mempool.RemoveUnbroadcastTx(txid, true); | ||||
} | } | ||||
} | } | ||||
if (g_avalanche && isAvalancheEnabled(gArgs)) { | if (g_avalanche && isAvalancheEnabled(gArgs)) { | ||||
g_avalanche->broadcastProofs(); | g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | ||||
auto unbroadcasted_proofids = pm.getUnbroadcastProofs(); | |||||
for (const auto &proofid : unbroadcasted_proofids) { | |||||
// Sanity check: all unbroadcast proofs should exist in the | |||||
// peermanager | |||||
if (pm.exists(proofid)) { | |||||
RelayProof(proofid, m_connman); | |||||
} else { | |||||
pm.removeUnbroadcastProof(proofid); | |||||
} | |||||
} | |||||
}); | |||||
} | } | ||||
// Schedule next run for 10-15 minutes in the future. | // Schedule next run for 10-15 minutes in the future. | ||||
// We add randomness on every cycle to avoid the possibility of P2P | // We add randomness on every cycle to avoid the possibility of P2P | ||||
// fingerprinting. | // fingerprinting. | ||||
const std::chrono::milliseconds delta = | const std::chrono::milliseconds delta = | ||||
std::chrono::minutes{10} + GetRandMillis(std::chrono::minutes{5}); | std::chrono::minutes{10} + GetRandMillis(std::chrono::minutes{5}); | ||||
scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, | scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, | ||||
▲ Show 20 Lines • Show All 4,741 Lines • Show Last 20 Lines |