mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
tidy: modernize-use-emplace
This commit is contained in:
@@ -2359,7 +2359,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
|
||||
// and we want it right after the last block so they don't
|
||||
// wait for other stuff first.
|
||||
std::vector<CInv> vInv;
|
||||
vInv.push_back(CInv(MSG_BLOCK, m_chainman.ActiveChain().Tip()->GetBlockHash()));
|
||||
vInv.emplace_back(MSG_BLOCK, m_chainman.ActiveChain().Tip()->GetBlockHash());
|
||||
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::INV, vInv));
|
||||
peer.m_continuation_block.SetNull();
|
||||
}
|
||||
@@ -2761,7 +2761,7 @@ void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, c
|
||||
break;
|
||||
}
|
||||
uint32_t nFetchFlags = GetFetchFlags(peer);
|
||||
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
|
||||
vGetData.emplace_back(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash());
|
||||
BlockRequested(pfrom.GetId(), *pindex);
|
||||
LogPrint(BCLog::NET, "Requesting block %s from peer=%d\n",
|
||||
pindex->GetBlockHash().ToString(), pfrom.GetId());
|
||||
@@ -3299,7 +3299,7 @@ void PeerManagerImpl::ProcessCompactBlockTxns(CNode& pfrom, Peer& peer, const Bl
|
||||
if (first_in_flight) {
|
||||
// Might have collided, fall back to getdata now :(
|
||||
std::vector<CInv> invs;
|
||||
invs.push_back(CInv(MSG_BLOCK | GetFetchFlags(peer), block_transactions.blockhash));
|
||||
invs.emplace_back(MSG_BLOCK | GetFetchFlags(peer), block_transactions.blockhash);
|
||||
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, invs));
|
||||
} else {
|
||||
RemoveBlockRequest(block_transactions.blockhash, pfrom.GetId());
|
||||
@@ -4149,7 +4149,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
LogPrint(BCLog::NET, "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), pfrom.GetId());
|
||||
for (; pindex; pindex = m_chainman.ActiveChain().Next(pindex))
|
||||
{
|
||||
vHeaders.push_back(pindex->GetBlockHeader());
|
||||
vHeaders.emplace_back(pindex->GetBlockHeader());
|
||||
if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop)
|
||||
break;
|
||||
}
|
||||
@@ -5649,14 +5649,14 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
pBestIndex = pindex;
|
||||
if (fFoundStartingHeader) {
|
||||
// add this to the headers message
|
||||
vHeaders.push_back(pindex->GetBlockHeader());
|
||||
vHeaders.emplace_back(pindex->GetBlockHeader());
|
||||
} else if (PeerHasHeader(&state, pindex)) {
|
||||
continue; // keep looking for the first new block
|
||||
} else if (pindex->pprev == nullptr || PeerHasHeader(&state, pindex->pprev)) {
|
||||
// Peer doesn't have this header but they do have the prior one.
|
||||
// Start sending headers.
|
||||
fFoundStartingHeader = true;
|
||||
vHeaders.push_back(pindex->GetBlockHeader());
|
||||
vHeaders.emplace_back(pindex->GetBlockHeader());
|
||||
} else {
|
||||
// Peer doesn't have this header or the prior one -- nothing will
|
||||
// connect, so bail out.
|
||||
@@ -5742,7 +5742,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
|
||||
// Add blocks
|
||||
for (const uint256& hash : peer->m_blocks_for_inv_relay) {
|
||||
vInv.push_back(CInv(MSG_BLOCK, hash));
|
||||
vInv.emplace_back(MSG_BLOCK, hash);
|
||||
if (vInv.size() == MAX_INV_SZ) {
|
||||
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
|
||||
vInv.clear();
|
||||
@@ -5948,7 +5948,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
}
|
||||
for (const CBlockIndex *pindex : vToDownload) {
|
||||
uint32_t nFetchFlags = GetFetchFlags(*peer);
|
||||
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
|
||||
vGetData.emplace_back(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash());
|
||||
BlockRequested(pto->GetId(), *pindex);
|
||||
LogPrint(BCLog::NET, "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),
|
||||
pindex->nHeight, pto->GetId());
|
||||
|
||||
Reference in New Issue
Block a user