Skip to content

Commit

Permalink
change variable names slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
mycognosist committed Feb 6, 2024
1 parent 65e4da2 commit 165bb4b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions solar/src/actors/replication/ebt/replicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,21 @@ pub async fn run(
trace!(target: "ebt-session", "Initiating EBT replication session with: {}", peer_ssb_id);

let mut session_initiated = false;
let mut replicate_req_no = None;
let mut active_req_no = None;

// Record the time at which we begin the EBT session.
//
// This is later used to implement a timeout if no request or response is
// received.
let ebt_session_start = Instant::now();

// TODO: Could this be moved into the MUXRPC EBT handler?
if let SessionRole::Requester = session_role {
// Send EBT request.
let ebt_args = EbtReplicate::default();
let req_no = api.ebt_replicate_req_send(&ebt_args).await?;
// Set the request number to be passed into the MUXRPC EBT handler.
// This allows tracking of the request (ensuring we respond to
// MUXRPC responses with this request number).
replicate_req_no = Some(req_no);

// Set the request number for this session.
active_req_no = Some(req_no);
}

loop {
Expand All @@ -111,7 +109,7 @@ pub async fn run(
if let Some(BrokerMessage::Ebt(EbtEvent::SessionInitiated(_connection_id, ref req_no, ref ssb_id, ref session_role))) = msg {
if peer_ssb_id == *ssb_id && *session_role == SessionRole::Responder {
session_initiated = true;
replicate_req_no = Some(*req_no);
active_req_no = Some(*req_no);
}
}
if let Some(msg) = msg {
Expand All @@ -127,9 +125,11 @@ pub async fn run(
&mut api,
&input,
&mut ch_broker,
// TODO: Can we remove this?
// We could look it up from the connection ID instead.
peer_ssb_id.to_owned(),
replicate_req_no,
connection_data.id,
active_req_no,
)
.await
{
Expand All @@ -142,7 +142,6 @@ pub async fn run(
Destination::Broadcast,
BrokerMessage::Ebt(EbtEvent::Error(
connection_data,
replicate_req_no,
peer_ssb_id.to_owned(),
err.to_string(),
)),
Expand Down

0 comments on commit 165bb4b

Please sign in to comment.