SAving, its broken

This commit is contained in:
Igor Katson 2023-12-05 20:02:54 +00:00
parent b15815d12f
commit efaa36a161
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
4 changed files with 67 additions and 43 deletions

View file

@ -53,9 +53,15 @@ pub(crate) struct Peer {
}
impl Peer {
pub fn new_live_for_incoming_connection(peer_id: Id20, tx: PeerTx) -> Self {
pub fn new_live_for_incoming_connection(
peer_id: Id20,
tx: PeerTx,
counters: &AggregatePeerStatsAtomic,
) -> Self {
let state = PeerStateNoMut(PeerState::Live(LivePeerState::new(peer_id, tx)));
counters.inc(&state.0);
Self {
state: PeerStateNoMut(PeerState::Live(LivePeerState::new(peer_id, tx))),
state,
stats: Default::default(),
}
}
@ -118,6 +124,13 @@ impl PeerStateNoMut {
std::mem::replace(&mut self.0, new)
}
pub fn get_live(&self) -> Option<&LivePeerState> {
match &self.0 {
PeerState::Live(l) => Some(l),
_ => None,
}
}
pub fn get_live_mut(&mut self) -> Option<&mut LivePeerState> {
match &mut self.0 {
PeerState::Live(l) => Some(l),