Skip to main content

Module peer_migration

Module peer_migration 

Source
Expand description

Peer state migration for seamless node handoff in P2P networks.

This module provides the infrastructure to migrate peer state (routing tables, provider records, connection metadata, etc.) from one node to another during planned handoffs or failover scenarios.

§Overview

When a node needs to leave the network gracefully (maintenance, scaling, etc.), its state must be transferred to one or more successor nodes to preserve network continuity. The PeerMigrationManager orchestrates this process through a structured state machine:

Idle -> Preparing -> Transferring -> Verifying -> Completed
                \         \              \
                 `--------> Failed <------'

§Key Features

  • Chunked transfer: Large state sets are broken into configurable chunks
  • Checksum verification: Integrity verification after transfer completion
  • Concurrent migration limits: Prevent resource exhaustion during bulk migrations
  • Progress tracking: Real-time progress reporting per migration
  • Statistics: Aggregate stats across all migrations for monitoring
  • Cleanup: Automatic pruning of completed migration records

Structs§

MigrationItem
A single item being migrated between peers.
PeerMigrationConfig
Configuration for the migration manager.
PeerMigrationManager
Manages peer state migrations for seamless node handoff.
PeerMigrationRecord
Record tracking a single migration between two peers.
PeerMigrationStats
Aggregate statistics across all migrations managed by a PeerMigrationManager.

Enums§

PeerMigrationState
State machine for a single peer migration operation.