mirror of
https://github.com/jmcorgan/fips.git
synced 2026-08-12 01:27:32 +00:00
Merge sole-store context change into the next-side
Bring the immutable-state single-store change onto the Noise XX line. The shared NodeContext is now the sole store; this merge applies the next-only adaptations the master-side change couldn't carry: - Remove node_profile from the Node struct (next-only field) so it lives solely in NodeContext; migrate its readers (tree/bloom/discovery/ handshake negotiation) onto the node_profile() accessor. The two FMP negotiation sites hoist node_profile() into a local to avoid borrowing &self while a connection is mutably borrowed. - leaf_only sets both is_leaf_only and node_profile via the context swap. - Preserve the XX handshake/rekey structure (no identity-in-msg1; XX/XK initiator/responder constructors) while applying the startup_epoch() accessor migration. - Tests: route profile selection through a make_test_node_with_profile helper (profile is immutable, set via Config flags) instead of poking the removed field. cargo test --lib 1369/0; clippy -D warnings and release build clean.
This commit is contained in:
+21
-6
@@ -28,14 +28,29 @@ pub(super) fn make_node() -> Node {
|
||||
make_node_with(Config::new())
|
||||
}
|
||||
|
||||
/// Build a test node from an explicit `Config`. Prefer this over poking
|
||||
/// `node.config.*` after construction: immutable fields are mirrored into the
|
||||
/// shared `NodeContext` at build time, so a post-construction field poke is
|
||||
/// invisible to any reader that has migrated onto the `config()` accessor.
|
||||
/// Build a test node from an explicit `Config`. Immutable state lives solely in
|
||||
/// the shared `NodeContext`, built once at construction — there is no
|
||||
/// post-construction field to poke, so set limits/config on the `Config` here.
|
||||
pub(super) fn make_node_with(config: Config) -> Node {
|
||||
Node::new(config).unwrap()
|
||||
}
|
||||
|
||||
/// Build a test node with an explicit `max_peers` limit (replaces the removed
|
||||
/// `set_max_peers` setter; resource limits are immutable post-construction).
|
||||
pub(super) fn make_node_with_max_peers(max_peers: usize) -> Node {
|
||||
let mut config = Config::new();
|
||||
config.node.limits.max_peers = max_peers;
|
||||
make_node_with(config)
|
||||
}
|
||||
|
||||
/// Build a test node with an explicit `max_links` limit (replaces the removed
|
||||
/// `set_max_links` setter; resource limits are immutable post-construction).
|
||||
pub(super) fn make_node_with_max_links(max_links: usize) -> Node {
|
||||
let mut config = Config::new();
|
||||
config.node.limits.max_links = max_links;
|
||||
make_node_with(config)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(super) fn make_node_addr(val: u8) -> NodeAddr {
|
||||
let mut bytes = [0u8; 16];
|
||||
@@ -66,9 +81,9 @@ pub(super) fn make_completed_connection(
|
||||
let mut conn = PeerConnection::outbound(link_id, peer_identity, current_time_ms);
|
||||
|
||||
// Run initiator side of handshake
|
||||
let our_keypair = node.identity.keypair();
|
||||
let our_keypair = node.identity().keypair();
|
||||
let msg1 = conn
|
||||
.start_handshake(our_keypair, node.startup_epoch, current_time_ms)
|
||||
.start_handshake(our_keypair, node.startup_epoch(), current_time_ms)
|
||||
.unwrap();
|
||||
|
||||
// Run responder side to generate msg2
|
||||
|
||||
Reference in New Issue
Block a user