5#include <chainparams.h>
66 unsigned char hsh[32];
81 const auto time{NodeClock::time_point::max()};
87 assert(msg.m_time == time);
106template<RandomNumberGenerator R>
118 std::array<std::vector<uint8_t>, 2>
in_flight;
121 std::array<std::deque<CSerializedNetMsg>, 2> expected;
124 std::array<std::vector<uint8_t>, 2>
to_send;
145 if (
c <
' ' ||
c > 0x7E)
break;
160 msg.m_type =
"version";
173 std::array<CSerializedNetMsg, 2>
next_msg = {
195 std::copy(bytes.begin(), bytes.end(),
to_send[
side].begin());
206 if (expected[
side].size() >= 16)
return;
227 if (bytes.empty())
return false;
271 auto received =
transports[!
side]->GetReceivedMessage({}, reject);
277 assert(received.m_message_size == received.m_recv.size());
279 assert(received.m_type == expected[
side].front().m_type);
282 expected[
side].pop_front();
326 assert(expected[0].empty());
327 assert(expected[1].empty());
335 return std::make_unique<V1Transport>(nodeid);
338template<RandomNumberGenerator RNG>
343 if (!key.IsValid())
return {};
346 std::vector<uint8_t>
garb;
369 return std::make_unique<V2Transport>(nodeid,
initiator, key,
ent, std::move(
garb));
381 if (!
t1 || !
t2)
return;
392 if (!
t1 || !
t2)
return;
403 if (!
t1 || !
t2)
return;
void SelectParams(const ChainType chain)
Sets the params returned by Params() to those for the given chain type.
const CChainParams & Params()
Return the currently selected parameters.
const MessageStartChars & MessageStart() const
A hasher class for Bitcoin's 256-bit hash (double SHA-256).
void Finalize(std::span< unsigned char > output)
CHash256 & Write(std::span< const unsigned char > input)
Transport protocol agnostic message container.
A hasher class for SHA-256.
void Finalize(unsigned char hash[OUTPUT_SIZE])
CSHA256 & Write(const unsigned char *data, size_t len)
RAII class initializing and deinitializing global state for elliptic curve support.
std::vector< T > ConsumeBytes(size_t num_bytes)
T ConsumeIntegralInRange(T min, T max)
std::vector< T > ConsumeRemainingBytes()
std::vector< B > randbytes(size_t len) noexcept
Generate random bytes.
The Transport converts one connection's sent messages to wire bytes, and received bytes back.
std::tuple< std::span< const uint8_t >, bool, const std::string & > BytesToSend
Return type for GetBytesToSend, consisting of:
static constexpr uint32_t MAX_GARBAGE_LEN
static const PrecomputedData data
Precomputed COutPoint and CCoins values.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
CSerializedNetMsg Make(std::string msg_type, Args &&... args)
const std::array ALL_NET_MESSAGE_TYPES
All known message types (see above).
auto MakeByteSpan(const V &v) noexcept
unsigned char * UCharCast(char *c)
FuzzedDataProvider provider
CKey ConsumePrivateKey(FuzzedDataProvider &fuzzed_data_provider, std::optional< bool > compressed) noexcept
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
FuzzedDataProvider & fuzzed_data_provider