MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / SetMessageToSend

Method SetMessageToSend

src/net.cpp:848–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

846}
847
848bool V1Transport::SetMessageToSend(CSerializedNetMsg& msg) noexcept
849{
850 AssertLockNotHeld(m_send_mutex);
851 // Determine whether a new message can be set.
852 LOCK(m_send_mutex);
853 if (m_sending_header || m_bytes_sent < m_message_to_send.data.size()) return false;
854
855 // create dbl-sha256 checksum
856 uint256 hash = Hash(msg.data);
857
858 // create header
859 CMessageHeader hdr(m_magic_bytes, msg.m_type.c_str(), msg.data.size());
860 memcpy(hdr.pchChecksum, hash.begin(), CMessageHeader::CHECKSUM_SIZE);
861
862 // serialize header
863 m_header_to_send.clear();
864 VectorWriter{m_header_to_send, 0, hdr};
865
866 // update state
867 m_message_to_send = std::move(msg);
868 m_sending_header = true;
869 m_bytes_sent = 0;
870 return true;
871}
872
873Transport::BytesToSend V1Transport::GetBytesToSend(bool have_next_message) const noexcept
874{

Callers 6

SocketSendDataMethod · 0.80
InteractMethod · 0.80
SimulationTestFunction · 0.80
ReceiveMsgFromMethod · 0.80
PushNetMsgMethod · 0.80

Calls 12

MakeByteSpanFunction · 0.85
MakeWritableByteSpanFunction · 0.85
ClearShrinkFunction · 0.85
HashFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
resizeMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
EncryptMethod · 0.45

Tested by 4

InteractMethod · 0.64
SimulationTestFunction · 0.64
ReceiveMsgFromMethod · 0.64
PushNetMsgMethod · 0.64