const INITIAL_COMMITMENT_NUMBER: u64 = (1 << 48) - 1;
+/// Liveness is called to fluctuate given peer disconnecton/monitor failures/closing.
+/// If channel is public, network should have a liveness view announced by us on a
+/// best-effort, which means we may filter out some status transitions to avoid spam.
+/// See further timer_chan_freshness_every_min.
+#[derive(PartialEq)]
+enum UpdateStatus {
+ /// Status has been gossiped.
+ Fresh,
+ /// Status has been changed.
+ DisabledMarked,
+ /// Status has been marked to be gossiped at next flush
+ DisabledStaged,
+}
+
// TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking
// has been completed, and then turn into a Channel to get compiler-time enforcement of things like
// calling channel_id() before we're set up or things like get_outbound_funding_signed on an
channel_monitor: ChannelMonitor,
+ network_sync: UpdateStatus,
+
logger: Arc<Logger>,
}
channel_monitor: channel_monitor,
+ network_sync: UpdateStatus::Fresh,
+
logger,
})
}
channel_monitor: channel_monitor,
+ network_sync: UpdateStatus::Fresh,
+
logger,
};
} else { false }
}
+ pub fn to_disabled_staged(&mut self) {
+ self.network_sync = UpdateStatus::DisabledStaged;
+ }
+
+ pub fn to_disabled_marked(&mut self) {
+ self.network_sync = UpdateStatus::DisabledMarked;
+ }
+
+ pub fn to_fresh(&mut self) {
+ self.network_sync = UpdateStatus::Fresh;
+ }
+
+ pub fn is_disabled_staged(&self) -> bool {
+ self.network_sync == UpdateStatus::DisabledStaged
+ }
+
+ pub fn is_disabled_marked(&self) -> bool {
+ self.network_sync == UpdateStatus::DisabledMarked
+ }
+
/// Called by channelmanager based on chain blocks being connected.
/// Note that we only need to use this to detect funding_signed, anything else is handled by
/// the channel_monitor.
channel_monitor,
+ network_sync: UpdateStatus::Fresh,
+
logger,
})
}
}
fn get_channel_keys(&self, _inbound: bool) -> ChannelKeys { self.chan_keys.clone() }
- fn get_session_key(&self) -> SecretKey { panic!(); }
+ fn get_onion_rand(&self) -> (SecretKey, [u8; 32]) { panic!(); }
fn get_channel_id(&self) -> [u8; 32] { [0; 32] }
}
let keys_provider: Arc<KeysInterface> = Arc::new(Keys { chan_keys });
let their_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
- let mut config = UserConfig::new();
+ let mut config = UserConfig::default();
config.channel_options.announced_channel = false;
let mut chan = Channel::new_outbound(&feeest, &keys_provider, their_node_id, 10000000, 100000, 42, Arc::clone(&logger), &config).unwrap(); // Nothing uses their network key in this test
chan.their_to_self_delay = 144;