Skip to content

Commit 04f849c

Browse files
committed
Add function for updating network graph with announcement with no UTXO resolver
1 parent bc54441 commit 04f849c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lightning/src/routing/gossip.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use crate::ln::msgs::{DecodeError, ErrorAction, Init, LightningError, RoutingMes
2828
use crate::ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, GossipTimestampFilter};
2929
use crate::ln::msgs::{QueryChannelRange, ReplyChannelRange, QueryShortChannelIds, ReplyShortChannelIdsEnd};
3030
use crate::ln::msgs;
31-
use crate::routing::utxo::{self, UtxoLookup};
31+
use crate::routing::utxo::{self, UtxoLookup, UtxoResolver};
3232
use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer, MaybeReadable};
3333
use crate::util::logger::{Logger, Level};
3434
use crate::util::scid_utils::{block_from_scid, scid_from_parts, MAX_SCID_BLOCK};
@@ -43,7 +43,7 @@ use core::convert::TryFrom;
4343
use crate::sync::{RwLock, RwLockReadGuard};
4444
#[cfg(feature = "std")]
4545
use core::sync::atomic::{AtomicUsize, Ordering};
46-
use crate::sync::Mutex;
46+
use crate::sync::{Arc, Mutex};
4747
use core::ops::{Bound, Deref};
4848
use core::str::FromStr;
4949

@@ -1458,6 +1458,19 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
14581458
self.update_channel_from_unsigned_announcement_intern(&msg.contents, Some(msg), utxo_lookup)
14591459
}
14601460

1461+
/// Store or update channel info from a channel announcement.
1462+
///
1463+
/// You probably don't want to call this directly, instead relying on a P2PGossipSync's
1464+
/// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
1465+
/// routing messages from a source using a protocol other than the lightning P2P protocol.
1466+
///
1467+
/// This will skip verification of if the channel is actually on-chain.
1468+
pub fn update_channel_from_announcement_no_lookup(
1469+
&self, msg: &ChannelAnnouncement
1470+
) -> Result<(), LightningError> {
1471+
self.update_channel_from_announcement::<Arc<UtxoResolver>>(msg, &None)
1472+
}
1473+
14611474
/// Store or update channel info from a channel announcement without verifying the associated
14621475
/// signatures. Because we aren't given the associated signatures here we cannot relay the
14631476
/// channel announcement to any of our peers.

lightning/src/routing/utxo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub struct UtxoFuture {
125125

126126
/// A trivial implementation of [`UtxoLookup`] which is used to call back into the network graph
127127
/// once we have a concrete resolution of a request.
128-
struct UtxoResolver(Result<TxOut, UtxoLookupError>);
128+
pub(crate) struct UtxoResolver(Result<TxOut, UtxoLookupError>);
129129
impl UtxoLookup for UtxoResolver {
130130
fn get_utxo(&self, _genesis_hash: &BlockHash, _short_channel_id: u64) -> UtxoResult {
131131
UtxoResult::Sync(self.0.clone())

0 commit comments

Comments
 (0)