Skip to content

Commit

Permalink
refactor(network): move event handling to its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin authored and maqi committed Apr 29, 2024
1 parent dae7561 commit b188590
Show file tree
Hide file tree
Showing 8 changed files with 1,909 additions and 1,867 deletions.
15 changes: 13 additions & 2 deletions sn_networking/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ use crate::{
cmd::SwarmCmd,
error::{NetworkError, Result},
event::{NetworkEvent, NodeEvent},
get_record_handler::PendingGetRecord,
multiaddr_pop_p2p,
network_discovery::NetworkDiscovery,
record_store::{ClientRecordStore, NodeRecordStore, NodeRecordStoreConfig},
record_store_api::UnifiedRecordStore,
relay_manager::RelayManager,
replication_fetcher::ReplicationFetcher,
target_arch::{interval, spawn, Instant},
Network, CLOSE_GROUP_SIZE,
GetRecordError, Network, CLOSE_GROUP_SIZE,
};
use crate::{transport, NodeIssue};
use futures::future::Either;
Expand Down Expand Up @@ -67,6 +66,7 @@ use std::{
use tokio::sync::{mpsc, oneshot};
use tokio::time::Duration;
use tracing::warn;
use xor_name::XorName;

/// Interval over which we check for the farthest record we _should_ be holding
/// based upon our knowledge of the CLOSE_GROUP
Expand All @@ -85,6 +85,17 @@ pub(crate) enum PendingGetClosestType {
}
type PendingGetClosest = HashMap<QueryId, (PendingGetClosestType, Vec<PeerId>)>;

/// Using XorName to differentiate different record content under the same key.
type GetRecordResultMap = HashMap<XorName, (Record, HashSet<PeerId>)>;
pub(crate) type PendingGetRecord = HashMap<
QueryId,
(
oneshot::Sender<std::result::Result<Record, GetRecordError>>,
GetRecordResultMap,
GetRecordCfg,
),
>;

/// What is the largest packet to send over the network.
/// Records larger than this will be rejected.
// TODO: revisit once cashnote_redemption is in
Expand Down
Loading

0 comments on commit b188590

Please sign in to comment.