Detached512#150
Draft
l0rinc wants to merge 25 commits into
Draft
Conversation
Script helpers derive these local counts and indexes from `std::span::size()`, but some of them were stored in signed integers or cast back to `size_t`. Keep the intermediate values in the span size type so the comparisons and subspan offsets no longer round-trip through signed values.
`MurmurHash3` derives its block count from the input span size, then uses it for pointer offsets into that same span. Store the count and loop index as `size_t` so the loop stays in the input size domain instead of converting through `int`.
The lockedpool benchmark masks into a vector index but stores the result in `int` before indexing the vector. Keep the local index as `size_t` so it uses the same type as the vector subscript and avoids an unnecessary signed round trip.
`NODE_NETWORK_LIMITED_MIN_BLOCKS` is only used with block-height deltas in `net_processing`, where the surrounding values are signed `int` heights. Keep the threshold in that domain and make it `constexpr`, removing the casts at both comparison sites.
Mempool acceptance stores transaction and package virtual sizes in wider or unsigned types and then casts them back for fee-rate calculations. Use the `int32_t` vsize type produced by mempool entries for accepted transactions and bounded packages. Package totals remain comfortably below `INT32_MAX` because context-free package policy limits them to `MAX_PACKAGE_COUNT` transactions and `MAX_PACKAGE_WEIGHT` total weight.
Replacement logging sums the virtual size of mempool transactions being removed, then subtracts it from the accepted transaction or package size. Store the conflict total in a signed wide type so the delta calculation no longer narrows the replaced size through `int` before logging.
RPC parameter indexes are compared with container positions, but a few helper paths stored them as `int` and cast the position back down. Store and pass these indexes as `size_t` so lookup and help generation use the same type as the argument vectors.
The headers message count is encoded as CompactSize, but `ProcessMessage` narrowed it to `unsigned int` before checking it against the configured maximum. Keep the decoded count in its wire type until the existing limit check has passed, then iterate the resized headers vector directly.
Coin selection reads package limit counts as unsigned values, widens them through `int64_t`, and then casts them back to `size_t` for filter construction. Clamp them directly as `size_t` values so the filter limits use the same type as the surrounding comparisons.
The multisig output parser validates the parsed key count as a small `uint32_t`, then casts it to `int` for the pubkey loop bound. Iterate with the parsed count type so the loop no longer bounces the key count through a signed integer.
`amount_tests` stores `INT_MAX` in an `int` and then casts it to `int64_t` at each expected-result calculation. Store the boundary value in the expected-result type directly so the multiplication checks do not need local casts.
`threadpool_tests` uses a small task count to size containers and compare future counts, but stores it in `int32_t` and casts it back to `size_t` throughout the range-submission test. Use `size_t` for the task count, generated range, task return type, and accumulators so the test stays in the container size domain.
The public decode functions accepted only `std::string` values and then forwarded through `c_str()` to nullable C-string helpers. Accept `std::string_view` at the API boundary and decode the view directly while preserving the embedded-NUL rejection.
Named argument hole counters track positions in `UniValue` arrays but used signed integers before comparing against array sizes. Keep those counters in `size_t` so the final positional-argument check no longer needs a size cast.
Several callers walked the `Network` enum by integer index and cast each value back to `Network` before skipping non-public entries. Iterate the public network values directly so the code no longer depends on local integer-to-enum roundtrips.
The HKDF helper accepted salt and info values as strings even though callers use them as byte sequences. Accept byte spans for HKDF input and output data so callers no longer need temporary stringification or local pointer casts.
`CHMAC_SHA256` callers with string or span-backed data had to pass raw unsigned-byte pointers and lengths manually. Add span overloads for input and output buffers, then use them in HKDF and RPC authentication code to keep byte data in span form.
The kernel import path code built a temporary string only to pass its C string into a path constructor. Use the existing PathFromString helper so the byte string to path conversion stays at the filesystem boundary.
GetReachableEmptyNetworks walks the Network enum as integers only to skip the unroutable and internal entries. Iterate the public networks directly so the loop states the domain it uses and avoids casting integers back to Network.
OpenNetworkConnection and ConnectNode used nullable C strings to distinguish named outbound connections from address-only connections. Use nullable string pointers instead so callers pass their existing string objects and C string access stays inside the connection code that needs it.
HMAC-SHA512 had the same pointer-and-length interface as HMAC-SHA256, forcing byte-span callers to cast at the call site. Add the matching span overloads and use them when deriving extended keys from a seed.
The rollback snapshot path derives its progress from block heights, which are signed values. Keep the local counters signed and wide enough for the percentage multiplication so the code no longer needs to cast height deltas through size_t.
Block filter lookup uses signed heights to walk the chain and size_t indexes to address result vectors. Keep those domains separate instead of recasting each height delta at the point of use.
Several SHA256 callers already hold byte spans, strings, or uint256 values and only cast them to unsigned char pointers for the hasher interface. Accept those spans at the CSHA256 boundary so callers can pass their byte-like data directly while the existing pointer API stays available.
These checks compare container sizes with signed limits or iterator distances. Use the C++20 comparison helpers instead of casting to a platform-dependent intermediate type or narrowing a queue size.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.