From 272bc567aae261a9d847256d0573d0bec39a2f3b Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Thu, 1 Sep 2022 09:36:35 -0700 Subject: [PATCH] policy setter in signer --- signer/src/lib.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/signer/src/lib.rs b/signer/src/lib.rs index 59b8653..e9e9ecc 100644 --- a/signer/src/lib.rs +++ b/signer/src/lib.rs @@ -27,6 +27,23 @@ pub struct InitResponse { pub const ROOT_STORE: &str = "/sdcard/store"; +pub fn set_policies( + root_handler: &RootHandler, + network: Network, + sats_per_day: u64, +) -> anyhow::Result<()> { + let mut policy = make_simple_policy(network); + policy.filter = PolicyFilter::new_permissive(); + let velocity_spec = VelocityControlSpec { + limit: sats_per_day, + interval_type: VelocityControlIntervalType::Daily, + }; + policy.global_velocity_control = velocity_spec; + let validator_factory = Arc::new(SimpleValidatorFactory::new_with_policy(policy)); + root_handler.node.set_validator_factory(validator_factory); + Ok(()) +} + pub fn init(bytes: Vec, network: Network) -> anyhow::Result { // let persister: Arc = Arc::new(DummyPersister); let mut md = MsgDriver::new(bytes); @@ -46,8 +63,8 @@ pub fn init(bytes: Vec, network: Network) -> anyhow::Result { let mut policy = make_simple_policy(network); policy.filter = PolicyFilter::new_permissive(); let velocity_spec = VelocityControlSpec { - limit: 10, - interval_type: VelocityControlIntervalType::Hourly, + limit: 1_000_000, // default a million sats per day + interval_type: VelocityControlIntervalType::Daily, }; policy.global_velocity_control = velocity_spec; let validator_factory = Arc::new(SimpleValidatorFactory::new_with_policy(policy));