Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcda66a2

Browse files
committed
Proper colony init and public index
1 parent5b39934 commitcda66a2

File tree

2 files changed

+65
-43
lines changed

2 files changed

+65
-43
lines changed

‎mutant-daemon/src/app.rs‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,39 @@ pub async fn run(options: AppOptions) -> Result<(), Error> {
238238
if is_public_only{" in public-only mode"} else{""});
239239

240240
// Store colony initialization parameters for later use when WebSocket clients connect
241-
// This allows the daemon to start serving requests immediately while colony functionality
242-
// is initialized on-demand with progress events sent to connected clients
243241
crate::handlers::colony::set_colony_init_params(network_choice, actual_private_key.clone()).await;
244242

243+
// Initialize colony manager at startup if we have a wallet (not in public-only mode)
244+
if !is_public_only{
245+
log::info!("Initializing colony manager at daemon startup...");
246+
247+
// Get wallet from MutAnt for colony initialization
248+
match mutant.get_wallet().await{
249+
Ok(wallet) =>{
250+
// Spawn colony manager initialization as async task to avoid blocking daemon startup
251+
let wallet_clone = wallet.clone();
252+
let network_choice_clone = network_choice;
253+
let private_key_clone = actual_private_key.clone();
254+
255+
tokio::spawn(asyncmove{
256+
matchcrate::handlers::colony::init_colony_manager(wallet_clone, network_choice_clone, private_key_clone).await{
257+
Ok(_) =>{
258+
log::info!("Colony manager initialized successfully at daemon startup");
259+
}
260+
Err(e) =>{
261+
log::warn!("Failed to initialize colony manager at startup: {}. Colony features will be available on-demand.", e);
262+
}
263+
}
264+
});
265+
}
266+
Err(e) =>{
267+
log::warn!("Failed to get wallet for colony initialization: {}. Colony features will be available on-demand.", e);
268+
}
269+
}
270+
}else{
271+
log::info!("Running in public-only mode, skipping colony manager initialization");
272+
}
273+
245274
// Initialize Task Management
246275
let tasks:TaskMap =Arc::new(RwLock::new(HashMap::new()));
247276
log::info!("Task manager initialized.");

‎mutant-web/src/app/put.rs‎

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,13 +1050,14 @@ impl PutWindow {
10501050
}
10511051
}
10521052
mutant_protocol::PutEvent::Complete =>{
1053-
log::info!("Put operationphasecompleted successfully");
1053+
log::info!("Put operation completed successfully");
10541054

1055-
//Check whichphasejust completed
1055+
//Forphasetracking, detect if this is the first completion (Phase 1)
10561056
let current_phase_val =*current_phase.read().unwrap();
1057+
let is_public = public;
10571058

1058-
if current_phase_val ==1{
1059-
// Phase 1(file data) is complete
1059+
ifis_public &&current_phase_val ==1{
1060+
//This is the end ofPhase 1for a public upload
10601061
*phase1_complete.write().unwrap() =true;
10611062

10621063
// Store Phase 1 progress
@@ -1065,34 +1066,19 @@ impl PutWindow {
10651066
*phase1_confirmation_progress.write().unwrap() =*confirmation_progress.read().unwrap();
10661067
*phase1_total_chunks.write().unwrap() =*total_chunks.read().unwrap();
10671068

1068-
if public{
1069-
// For public uploads, move to Phase 2 (public index upload)
1070-
*current_phase.write().unwrap() =2;
1071-
1072-
// Reset current progress for Phase 2
1073-
*reservation_progress.write().unwrap() =0.0;
1074-
*upload_progress.write().unwrap() =0.0;
1075-
*confirmation_progress.write().unwrap() =0.0;
1076-
*total_chunks.write().unwrap() =0;
1077-
1078-
// Don't mark as complete yet - wait for Phase 2
1079-
log::info!("Phase 1 complete, waiting for Phase 2 (public index upload)");
1080-
// Continue listening for Phase 2 events
1081-
}else{
1082-
// For private uploads, we're done after Phase 1
1083-
*upload_complete_clone.write().unwrap() =true;
1084-
*is_uploading_clone.write().unwrap() =false;
1085-
1086-
// Refresh the keys list
1087-
spawn_local(asyncmove{
1088-
let ctx = context::context();
1089-
let _ = ctx.list_keys().await;
1090-
});
1091-
1092-
break;
1093-
}
1094-
}elseif current_phase_val ==2{
1095-
// Phase 2 (public index) is complete
1069+
// Move to Phase 2 for UI display
1070+
*current_phase.write().unwrap() =2;
1071+
1072+
// Reset current progress for Phase 2 display
1073+
*reservation_progress.write().unwrap() =0.0;
1074+
*upload_progress.write().unwrap() =0.0;
1075+
*confirmation_progress.write().unwrap() =0.0;
1076+
*total_chunks.write().unwrap() =0;
1077+
1078+
log::info!("Phase 1 complete, transitioning to Phase 2 display");
1079+
// Continue listening for Phase 2 events - don't break yet
1080+
}elseif is_public && current_phase_val ==2{
1081+
// This is the end of Phase 2 for a public upload
10961082
*phase2_complete.write().unwrap() =true;
10971083

10981084
// Store Phase 2 progress
@@ -1101,7 +1087,12 @@ impl PutWindow {
11011087
*phase2_confirmation_progress.write().unwrap() =*confirmation_progress.read().unwrap();
11021088
*phase2_total_chunks.write().unwrap() =*total_chunks.read().unwrap();
11031089

1104-
// Both phases complete for public upload
1090+
log::info!("Phase 2 complete, continuing to listen for final completion");
1091+
// Continue listening - the daemon will send final completion after auto-indexing
1092+
}else{
1093+
// This is either:
1094+
// 1. A private upload completion (single phase)
1095+
// 2. The final completion for a public upload (after auto-indexing)
11051096
*upload_complete_clone.write().unwrap() =true;
11061097
*is_uploading_clone.write().unwrap() =false;
11071098

@@ -1110,19 +1101,21 @@ impl PutWindow {
11101101
let ctx = context::context();
11111102
let _ = ctx.list_keys().await;
11121103

1113-
// Fetch the key details to get the public address
1114-
let keys = ctx.list_keys().await;
1115-
for keyin keys{
1116-
if key.key == key_name_clone && key.is_public{
1117-
ifletSome(addr) = key.public_address{
1118-
*public_address.write().unwrap() =Some(addr);
1119-
break;
1104+
// For public uploads, fetch the public address
1105+
if is_public{
1106+
let keys = ctx.list_keys().await;
1107+
for keyin keys{
1108+
if key.key == key_name_clone && key.is_public{
1109+
ifletSome(addr) = key.public_address{
1110+
*public_address.write().unwrap() =Some(addr);
1111+
break;
1112+
}
11201113
}
11211114
}
11221115
}
11231116
});
11241117

1125-
log::info!("Phase 2 complete, public upload finished");
1118+
log::info!("Upload completed successfully");
11261119
break;
11271120
}
11281121
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp