]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Reorder struct definitions so that they are in dependency order.
authorMatt Corallo <git@bluematt.me>
Thu, 11 Jun 2020 19:34:28 +0000 (15:34 -0400)
committerMatt Corallo <git@bluematt.me>
Tue, 25 Aug 2020 21:09:02 +0000 (17:09 -0400)
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
lightning/src/util/config.rs

index 89c19b84896bdb37c4644322871131461bf8354c..0dafc105bd20a1a531a3ac07b67fbcfe7604d1a9 100644 (file)
@@ -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<u64, ChannelInfo>,
+       nodes: BTreeMap<PublicKey, NodeInfo>,
+}
+
 /// 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<u64, ChannelInfo>,
-       nodes: BTreeMap<PublicKey, NodeInfo>,
-}
-
 impl Writeable for NetworkGraph {
        fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
                (self.channels.len() as u64).write(writer)?;
index c3726365996ae5b5cff69448aeb33c766ce82b54..712b5937bab7ea2517f41cef155a7fe8d707c2b9 100644 (file)
 
 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(),
+               }
+       }
+}