use alloc::{fmt, vec::Vec};
use binary_sv2::{self, Deserialize, Serialize, Str0255, U256};
use core::convert::TryInto;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct UpdateChannel<'decoder> {
pub channel_id: u32,
pub nominal_hash_rate: f32,
pub maximum_target: U256<'decoder>,
}
impl fmt::Display for UpdateChannel<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"⛏️ UpdateChannel(channel_id={}, nominal_hash_rate={}, maximum_target={})",
self.channel_id, self.nominal_hash_rate, self.maximum_target
)
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct UpdateChannelError<'decoder> {
pub channel_id: u32,
pub error_code: Str0255<'decoder>,
}
impl fmt::Display for UpdateChannelError<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"UpdateChannelError(channel_id={}, error_code={})",
self.channel_id,
self.error_code.as_utf8_or_hex()
)
}
}