From 4441a06dee6967fd9667f8d07a666b3ed7ed1a3a Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 11 Jun 2020 15:34:28 -0400 Subject: [PATCH] Reorder struct definitions so that they are in dependency order. There are a few cases where the upcoming C bindings don't know how to handle something which depends on something defined later in the file. Instead of adding another pass to the C bindings generator, it is much simpler to just reorder structs. --- lightning/src/routing/network_graph.rs | 14 ++++---- lightning/src/util/config.rs | 48 +++++++++++++------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lightning/src/routing/network_graph.rs b/lightning/src/routing/network_graph.rs index 89c19b848..0dafc105b 100644 --- a/lightning/src/routing/network_graph.rs +++ b/lightning/src/routing/network_graph.rs @@ -33,6 +33,13 @@ use std::collections::btree_map::Entry as BtreeEntry; use std::ops::Deref; use bitcoin::hashes::hex::ToHex; +/// Represents the network as nodes and channels between them +#[derive(PartialEq)] +pub struct NetworkGraph { + channels: BTreeMap, + nodes: BTreeMap, +} + /// Receives and validates network updates from peers, /// stores authentic and relevant data as a network graph. /// This network graph is then used for routing payments. @@ -443,13 +450,6 @@ impl Readable for NodeInfo { } } -/// Represents the network as nodes and channels between them -#[derive(PartialEq)] -pub struct NetworkGraph { - channels: BTreeMap, - nodes: BTreeMap, -} - impl Writeable for NetworkGraph { fn write(&self, writer: &mut W) -> Result<(), ::std::io::Error> { (self.channels.len() as u64).write(writer)?; diff --git a/lightning/src/util/config.rs b/lightning/src/util/config.rs index c37263659..712b5937b 100644 --- a/lightning/src/util/config.rs +++ b/lightning/src/util/config.rs @@ -12,30 +12,6 @@ use ln::channelmanager::{BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT}; -/// Top-level config which holds ChannelHandshakeLimits and ChannelConfig. -/// -/// Default::default() provides sane defaults for most configurations -/// (but currently with 0 relay fees!) -#[derive(Clone, Debug)] -pub struct UserConfig { - /// Channel config that we propose to our counterparty. - pub own_channel_config: ChannelHandshakeConfig, - /// Limits applied to our counterparty's proposed channel config settings. - pub peer_channel_config_limits: ChannelHandshakeLimits, - /// Channel config which affects behavior during channel lifetime. - pub channel_options: ChannelConfig, -} - -impl Default for UserConfig { - fn default() -> Self { - UserConfig { - own_channel_config: ChannelHandshakeConfig::default(), - peer_channel_config_limits: ChannelHandshakeLimits::default(), - channel_options: ChannelConfig::default(), - } - } -} - /// Configuration we set when applicable. /// /// Default::default() provides sane defaults. @@ -228,3 +204,27 @@ impl_writeable!(ChannelConfig, 8+1+1, { announced_channel, commit_upfront_shutdown_pubkey }); + +/// Top-level config which holds ChannelHandshakeLimits and ChannelConfig. +/// +/// Default::default() provides sane defaults for most configurations +/// (but currently with 0 relay fees!) +#[derive(Clone, Debug)] +pub struct UserConfig { + /// Channel config that we propose to our counterparty. + pub own_channel_config: ChannelHandshakeConfig, + /// Limits applied to our counterparty's proposed channel config settings. + pub peer_channel_config_limits: ChannelHandshakeLimits, + /// Channel config which affects behavior during channel lifetime. + pub channel_options: ChannelConfig, +} + +impl Default for UserConfig { + fn default() -> Self { + UserConfig { + own_channel_config: ChannelHandshakeConfig::default(), + peer_channel_config_limits: ChannelHandshakeLimits::default(), + channel_options: ChannelConfig::default(), + } + } +} -- 2.39.5