-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: MSP move bucket #276
Changes from all commits
4f1ffce
0f1a1d7
48eabac
7769053
40bd7f1
971224a
3de92d6
0947db8
5ebb44c
ec22995
3938346
3ae9f99
8138204
0c29469
5684d96
c7e0961
7087ede
cd3bef2
2be6d60
42dc99d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,8 +52,9 @@ use crate::{ | |
events::{ | ||
AcceptedBspVolunteer, BlockchainServiceEventBusProvider, BspConfirmStoppedStoring, | ||
FinalisedBspConfirmStoppedStoring, FinalisedMspStoppedStoringBucket, | ||
FinalisedTrieRemoveMutationsApplied, LastChargeableInfoUpdated, NewStorageRequest, | ||
SlashableProvider, SpStopStoringInsolventUser, UserWithoutFunds, | ||
FinalisedTrieRemoveMutationsApplied, LastChargeableInfoUpdated, MoveBucketAccepted, | ||
MoveBucketExpired, MoveBucketRejected, MoveBucketRequested, MoveBucketRequestedForNewMsp, | ||
NewStorageRequest, SlashableProvider, SpStopStoringInsolventUser, UserWithoutFunds, | ||
}, | ||
state::{ | ||
BlockchainServiceStateStore, LastProcessedBlockNumberCf, | ||
|
@@ -504,7 +505,8 @@ impl Actor for BlockchainService { | |
.unwrap_or_else(|_| { | ||
error!(target: LOG_TARGET, "Failed to query provider multiaddresses"); | ||
Err(QueryProviderMultiaddressesError::InternalError) | ||
}); | ||
}) | ||
.map(convert_raw_multiaddresses_to_multiaddr); | ||
|
||
match callback.send(multiaddresses) { | ||
Ok(_) => { | ||
|
@@ -1248,6 +1250,39 @@ impl BlockchainService { | |
size, | ||
}) | ||
} | ||
RuntimeEvent::FileSystem( | ||
pallet_file_system::Event::MoveBucketRequested { | ||
who: _, | ||
bucket_id, | ||
new_msp_id, | ||
}, | ||
) => { | ||
self.emit(MoveBucketRequested { | ||
bucket_id, | ||
new_msp_id, | ||
}); | ||
if self.provider_ids.contains(&new_msp_id) { | ||
self.emit(MoveBucketRequestedForNewMsp { bucket_id }); | ||
} | ||
} | ||
RuntimeEvent::FileSystem( | ||
pallet_file_system::Event::MoveBucketRejected { bucket_id, msp_id }, | ||
) => { | ||
self.emit(MoveBucketRejected { bucket_id, msp_id }); | ||
} | ||
RuntimeEvent::FileSystem( | ||
pallet_file_system::Event::MoveBucketAccepted { bucket_id, msp_id }, | ||
) => { | ||
self.emit(MoveBucketAccepted { bucket_id, msp_id }); | ||
} | ||
RuntimeEvent::FileSystem( | ||
pallet_file_system::Event::MoveBucketRequestExpired { | ||
bucket_id, | ||
msp_id, | ||
}, | ||
) => { | ||
self.emit(MoveBucketExpired { bucket_id, msp_id }); | ||
} | ||
Comment on lines
+1268
to
+1285
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand that these are events intended a BSP node, is that right? In that case, when my PR is merged with the changes to |
||
RuntimeEvent::FileSystem( | ||
pallet_file_system::Event::BspConfirmStoppedStoring { | ||
bsp_id, | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -57,21 +57,25 @@ pub fn get_events_at_block( | |||||
pub fn convert_raw_multiaddresses_to_multiaddr(multiaddresses: Multiaddresses) -> Vec<Multiaddr> { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
let mut multiaddress_vec: Vec<Multiaddr> = Vec::new(); | ||||||
for raw_multiaddr in multiaddresses.into_iter() { | ||||||
let multiaddress = match std::str::from_utf8(&raw_multiaddr) { | ||||||
Ok(s) => match Multiaddr::from_str(s) { | ||||||
Ok(multiaddr) => multiaddr, | ||||||
Err(e) => { | ||||||
error!("Failed to parse Multiaddress from string: {:?}", e); | ||||||
continue; | ||||||
} | ||||||
}, | ||||||
if let Some(multiaddress) = convert_raw_multiaddress_to_multiaddr(&raw_multiaddr) { | ||||||
multiaddress_vec.push(multiaddress); | ||||||
} | ||||||
} | ||||||
multiaddress_vec | ||||||
} | ||||||
|
||||||
pub fn convert_raw_multiaddress_to_multiaddr(raw_multiaddr: &[u8]) -> Option<Multiaddr> { | ||||||
Comment on lines
57
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about making these two return a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would the behaviour be, when would there be an error? Right now |
||||||
match std::str::from_utf8(raw_multiaddr) { | ||||||
Ok(s) => match Multiaddr::from_str(s) { | ||||||
Ok(multiaddr) => Some(multiaddr), | ||||||
Err(e) => { | ||||||
error!("Failed to parse Multiaddress from bytes: {:?}", e); | ||||||
continue; | ||||||
error!("Failed to parse Multiaddress from string: {:?}", e); | ||||||
None | ||||||
} | ||||||
}; | ||||||
|
||||||
multiaddress_vec.push(multiaddress); | ||||||
}, | ||||||
Err(e) => { | ||||||
error!("Failed to parse Multiaddress from bytes: {:?}", e); | ||||||
None | ||||||
} | ||||||
} | ||||||
multiaddress_vec | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, what happened to events that were not listened by any task? For example an MSP running a node, would emit this event internally, but no one would be listening to it. Did it get cleared somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no subscriber - nothing really, they get dropped.