projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a4a54ed
)
Implement core::hash::Hash more incl invoice::RawTaggedField
author
Matt Corallo
<git@bluematt.me>
Tue, 24 Aug 2021 21:00:17 +0000
(21:00 +0000)
committer
Matt Corallo
<git@bluematt.me>
Tue, 31 Aug 2021 21:29:51 +0000
(21:29 +0000)
lightning-invoice/src/lib.rs
patch
|
blob
|
history
lightning/src/ln/features.rs
patch
|
blob
|
history
lightning/src/routing/network_graph.rs
patch
|
blob
|
history
lightning/src/routing/router.rs
patch
|
blob
|
history
diff --git
a/lightning-invoice/src/lib.rs
b/lightning-invoice/src/lib.rs
index 75aac5491513840c433ed17a6b785ff791aa646c..bf92dba573c81b04176b0eeb5133bc7262685d2d 100644
(file)
--- a/
lightning-invoice/src/lib.rs
+++ b/
lightning-invoice/src/lib.rs
@@
-321,7
+321,7
@@
impl SiPrefix {
}
/// Enum representing the crypto currencies (or networks) supported by this library
}
/// Enum representing the crypto currencies (or networks) supported by this library
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub enum Currency {
/// Bitcoin mainnet
Bitcoin,
pub enum Currency {
/// Bitcoin mainnet
Bitcoin,
@@
-342,7
+342,7
@@
pub enum Currency {
/// Tagged field which may have an unknown tag
///
/// (C-not exported) as we don't currently support TaggedField
/// Tagged field which may have an unknown tag
///
/// (C-not exported) as we don't currently support TaggedField
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub enum RawTaggedField {
/// Parsed tagged field with known tag
KnownSemantics(TaggedField),
pub enum RawTaggedField {
/// Parsed tagged field with known tag
KnownSemantics(TaggedField),
@@
-357,7
+357,7
@@
pub enum RawTaggedField {
/// (C-not exported) As we don't yet support enum variants with the same name the struct contained
/// in the variant.
#[allow(missing_docs)]
/// (C-not exported) As we don't yet support enum variants with the same name the struct contained
/// in the variant.
#[allow(missing_docs)]
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub enum TaggedField {
PaymentHash(Sha256),
Description(Description),
pub enum TaggedField {
PaymentHash(Sha256),
Description(Description),
@@
-372,18
+372,18
@@
pub enum TaggedField {
}
/// SHA-256 hash
}
/// SHA-256 hash
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub struct Sha256(pub sha256::Hash);
/// Description string
///
/// # Invariants
/// The description can be at most 639 __bytes__ long
pub struct Sha256(pub sha256::Hash);
/// Description string
///
/// # Invariants
/// The description can be at most 639 __bytes__ long
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub struct Description(String);
/// Payee public key
pub struct Description(String);
/// Payee public key
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub struct PayeePubKey(pub PublicKey);
/// Positive duration that defines when (relatively to the timestamp) in the future the invoice
pub struct PayeePubKey(pub PublicKey);
/// Positive duration that defines when (relatively to the timestamp) in the future the invoice
@@
-393,17
+393,17
@@
pub struct PayeePubKey(pub PublicKey);
/// The number of seconds this expiry time represents has to be in the range
/// `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a
/// timestamp
/// The number of seconds this expiry time represents has to be in the range
/// `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a
/// timestamp
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub struct ExpiryTime(Duration);
/// `min_final_cltv_expiry` to use for the last HTLC in the route
pub struct ExpiryTime(Duration);
/// `min_final_cltv_expiry` to use for the last HTLC in the route
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub struct MinFinalCltvExpiry(pub u64);
// TODO: better types instead onf byte arrays
/// Fallback address in case no LN payment is possible
#[allow(missing_docs)]
pub struct MinFinalCltvExpiry(pub u64);
// TODO: better types instead onf byte arrays
/// Fallback address in case no LN payment is possible
#[allow(missing_docs)]
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub enum Fallback {
SegWitProgram {
version: u5,
pub enum Fallback {
SegWitProgram {
version: u5,
@@
-414,7
+414,7
@@
pub enum Fallback {
}
/// Recoverable signature
}
/// Recoverable signature
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Eq, PartialEq
)]
pub struct InvoiceSignature(pub RecoverableSignature);
/// Private routing information
pub struct InvoiceSignature(pub RecoverableSignature);
/// Private routing information
@@
-422,7
+422,7
@@
pub struct InvoiceSignature(pub RecoverableSignature);
/// # Invariants
/// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
///
/// # Invariants
/// The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops)
///
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub struct PrivateRoute(RouteHint);
/// Tag constants as specified in BOLT11
pub struct PrivateRoute(RouteHint);
/// Tag constants as specified in BOLT11
diff --git
a/lightning/src/ln/features.rs
b/lightning/src/ln/features.rs
index c0eb8f68ac541c4ed5181713686141bd7d287139..d1f6b89db4f87e968e3624289331c00c476875fe 100644
(file)
--- a/
lightning/src/ln/features.rs
+++ b/
lightning/src/ln/features.rs
@@
-25,6
+25,7
@@
use io;
use prelude::*;
use core::{cmp, fmt};
use io;
use prelude::*;
use core::{cmp, fmt};
+use core::hash::{Hash, Hasher};
use core::marker::PhantomData;
use bitcoin::bech32;
use core::marker::PhantomData;
use bitcoin::bech32;
@@
-362,6
+363,11
@@
impl<T: sealed::Context> Clone for Features<T> {
}
}
}
}
}
}
+impl<T: sealed::Context> Hash for Features<T> {
+ fn hash<H: Hasher>(&self, hasher: &mut H) {
+ self.flags.hash(hasher);
+ }
+}
impl<T: sealed::Context> PartialEq for Features<T> {
fn eq(&self, o: &Self) -> bool {
self.flags.eq(&o.flags)
impl<T: sealed::Context> PartialEq for Features<T> {
fn eq(&self, o: &Self) -> bool {
self.flags.eq(&o.flags)
diff --git
a/lightning/src/routing/network_graph.rs
b/lightning/src/routing/network_graph.rs
index 486b71578f3fde8775e1d7fe86bd0283c5ef7d8e..8accdab60882321dea801497643478b702a21b47 100644
(file)
--- a/
lightning/src/routing/network_graph.rs
+++ b/
lightning/src/routing/network_graph.rs
@@
-533,7
+533,7
@@
impl_writeable_tlv_based!(ChannelInfo, {
/// Fees for routing via a given channel or a node
/// Fees for routing via a given channel or a node
-#[derive(Eq, PartialEq, Copy, Clone, Debug)]
+#[derive(Eq, PartialEq, Copy, Clone, Debug
, Hash
)]
pub struct RoutingFees {
/// Flat routing fee in satoshis
pub base_msat: u32,
pub struct RoutingFees {
/// Flat routing fee in satoshis
pub base_msat: u32,
diff --git
a/lightning/src/routing/router.rs
b/lightning/src/routing/router.rs
index 13356cc1c74334193fed69be42a05b718d2ab89d..ea55ce1a9d004940dae4441c85b0a550bcf4aed7 100644
(file)
--- a/
lightning/src/routing/router.rs
+++ b/
lightning/src/routing/router.rs
@@
-28,7
+28,7
@@
use core::cmp;
use core::ops::Deref;
/// A hop in a route
use core::ops::Deref;
/// A hop in a route
-#[derive(Clone,
Partial
Eq)]
+#[derive(Clone,
Hash, PartialEq,
Eq)]
pub struct RouteHop {
/// The node_id of the node at this hop.
pub pubkey: PublicKey,
pub struct RouteHop {
/// The node_id of the node at this hop.
pub pubkey: PublicKey,
@@
-60,7
+60,7
@@
impl_writeable_tlv_based!(RouteHop, {
/// A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
/// it can take multiple paths. Each path is composed of one or more hops through the network.
/// A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
/// it can take multiple paths. Each path is composed of one or more hops through the network.
-#[derive(Clone,
Partial
Eq)]
+#[derive(Clone,
Hash, PartialEq,
Eq)]
pub struct Route {
/// The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
/// last RouteHop in each path must be the same.
pub struct Route {
/// The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
/// last RouteHop in each path must be the same.
@@
-108,11
+108,11
@@
impl Readable for Route {
}
/// A list of hops along a payment path terminating with a channel to the recipient.
}
/// A list of hops along a payment path terminating with a channel to the recipient.
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub struct RouteHint(pub Vec<RouteHintHop>);
/// A channel descriptor for a hop along a payment path.
pub struct RouteHint(pub Vec<RouteHintHop>);
/// A channel descriptor for a hop along a payment path.
-#[derive(
Eq, PartialEq, Debug, Clone
)]
+#[derive(
Clone, Debug, Hash, Eq, PartialEq
)]
pub struct RouteHintHop {
/// The node_id of the non-target end of the route
pub src_node_id: PublicKey,
pub struct RouteHintHop {
/// The node_id of the non-target end of the route
pub src_node_id: PublicKey,