-
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: add task to let MSP charge user every X blocks #268
base: main
Are you sure you want to change the base?
Changes from 1 commit
120b859
e18b537
e8e5513
ae0aa49
d7c3132
d33576b
ad5dbcf
583b1e7
e250967
dde2b66
578d56c
476bc83
9ffcc39
9ba6ecb
bbe8fa2
ce94d04
11998d3
f8e0feb
b674933
8000da1
4e760ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,7 @@ | |
max_storage_capacity: Option<StorageDataUnit>, | ||
jump_capacity: Option<StorageDataUnit>, | ||
extrinsic_retry_timeout: u64, | ||
notify_period: Option<u32>, | ||
} | ||
|
||
/// Common components to build for any given configuration of [`RoleSupport`] and [`StorageLayerSupport`]. | ||
|
@@ -125,6 +126,7 @@ | |
max_storage_capacity: None, | ||
jump_capacity: None, | ||
extrinsic_retry_timeout: DEFAULT_EXTRINSIC_RETRY_TIMEOUT_SECONDS, | ||
notify_period: None, | ||
} | ||
} | ||
|
||
|
@@ -166,6 +168,18 @@ | |
self | ||
} | ||
|
||
// TODO: add a function ´with_notify_period´ to be called in the service. | ||
// but check that ´blockchain´ is None (so we don't have called with_blockchain before) | ||
undercover-cactus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub fn with_notify_period(&mut self, notify_period: u32) -> &mut Self { | ||
if self.blockchain.is_some() { | ||
panic!( | ||
"`with_notify_period`should never be called after starting the blockchain service." | ||
); | ||
} | ||
self.notify_period = Some(notify_period); | ||
self | ||
} | ||
|
||
pub async fn with_blockchain( | ||
&mut self, | ||
client: Arc<ParachainClient>, | ||
|
@@ -181,6 +195,7 @@ | |
rpc_handlers.clone(), | ||
keystore.clone(), | ||
rocksdb_root_path, | ||
self.notify_period, | ||
) | ||
.await; | ||
|
||
|
@@ -410,6 +425,7 @@ | |
max_storage_capacity: Option<StorageDataUnit>, | ||
jump_capacity: Option<StorageDataUnit>, | ||
extrinsic_retry_timeout: u64, | ||
msp_charging_freq: Option<u32>, | ||
); | ||
} | ||
|
||
|
@@ -424,11 +440,16 @@ | |
max_storage_capacity: Option<StorageDataUnit>, | ||
jump_capacity: Option<StorageDataUnit>, | ||
extrinsic_retry_timeout: u64, | ||
msp_charging_freq: Option<u32>, | ||
) { | ||
self.setup_storage_layer(storage_path); | ||
if max_storage_capacity.is_none() { | ||
panic!("Max storage capacity not set"); | ||
} | ||
if let Some(notify_period) = msp_charging_freq { | ||
self.with_notify_period(notify_period.clone()); | ||
} | ||
|
||
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 am not super happy for having to do this with all different 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. Agreed. In fact all the functions that are not storage-layer-or-provider-type-specific (i.e. that they don't need to have a special implementation for a provider type and storage layer), I'd leave them out of this In other words, to make proper use of the builder pattern I would:
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. Anyway, I'd like to get @snowmead involved since he was heavily involved in this code. |
||
self.with_max_storage_capacity(max_storage_capacity); | ||
self.with_jump_capacity(jump_capacity); | ||
self.with_retry_timeout(extrinsic_retry_timeout); | ||
|
@@ -446,6 +467,7 @@ | |
max_storage_capacity: Option<StorageDataUnit>, | ||
jump_capacity: Option<StorageDataUnit>, | ||
extrinsic_retry_timeout: u64, | ||
msp_charging_freq: Option<u32>, | ||
) { | ||
if storage_path.is_none() { | ||
panic!("Storage path not set"); | ||
|
@@ -454,6 +476,9 @@ | |
if max_storage_capacity.is_none() { | ||
panic!("Max storage capacity not set"); | ||
} | ||
if let Some(notify_period) = msp_charging_freq { | ||
self.with_notify_period(notify_period.clone()); | ||
} | ||
self.with_max_storage_capacity(max_storage_capacity); | ||
self.with_jump_capacity(jump_capacity); | ||
self.with_retry_timeout(extrinsic_retry_timeout); | ||
|
@@ -471,11 +496,15 @@ | |
max_storage_capacity: Option<StorageDataUnit>, | ||
jump_capacity: Option<StorageDataUnit>, | ||
extrinsic_retry_timeout: u64, | ||
msp_charging_freq: Option<u32>, | ||
) { | ||
self.setup_storage_layer(storage_path); | ||
if max_storage_capacity.is_none() { | ||
panic!("Max storage capacity not set"); | ||
} | ||
if let Some(notify_period) = msp_charging_freq { | ||
self.with_notify_period(notify_period.clone()); | ||
} | ||
self.with_max_storage_capacity(max_storage_capacity); | ||
self.with_jump_capacity(jump_capacity); | ||
self.with_retry_timeout(extrinsic_retry_timeout); | ||
|
@@ -493,6 +522,7 @@ | |
max_storage_capacity: Option<StorageDataUnit>, | ||
jump_capacity: Option<StorageDataUnit>, | ||
extrinsic_retry_timeout: u64, | ||
msp_charging_freq: Option<u32>, | ||
) { | ||
if storage_path.is_none() { | ||
panic!("Storage path not set"); | ||
|
@@ -501,6 +531,9 @@ | |
if max_storage_capacity.is_none() { | ||
panic!("Max storage capacity not set"); | ||
} | ||
if let Some(notify_period) = msp_charging_freq { | ||
self.with_notify_period(notify_period.clone()); | ||
} | ||
self.with_max_storage_capacity(max_storage_capacity); | ||
self.with_jump_capacity(jump_capacity); | ||
self.with_retry_timeout(extrinsic_retry_timeout); | ||
|
@@ -518,7 +551,11 @@ | |
_max_storage_capacity: Option<StorageDataUnit>, | ||
_jump_capacity: Option<StorageDataUnit>, | ||
extrinsic_retry_timeout: u64, | ||
msp_charging_freq: Option<u32>, | ||
) { | ||
if let Some(notify_period) = msp_charging_freq { | ||
self.with_notify_period(notify_period.clone()); | ||
} | ||
self.setup_storage_layer(None); | ||
self.with_retry_timeout(extrinsic_retry_timeout); | ||
} | ||
|
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.
This fits better in
utils.rs