Skip to content

Commit 3876a14

Browse files
committed
Update auto-generated bindings for backport of RGS-no-std support
1 parent f9ebaf4 commit 3876a14

File tree

3 files changed

+39
-66
lines changed

3 files changed

+39
-66
lines changed

lightning-c-bindings/include/lightning.h

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13501,7 +13501,8 @@ typedef struct MUST_USE_STRUCT LDKBackgroundProcessor {
1350113501

1350213502

1350313503
/**
13504-
* Rapid Gossip Sync struct
13504+
* The main Rapid Gossip Sync object.
13505+
*
1350513506
* See [crate-level documentation] for usage.
1350613507
*
1350713508
* [crate-level documentation]: crate
@@ -30843,23 +30844,22 @@ struct LDKStr SiPrefix_to_str(const enum LDKSiPrefix *NONNULL_PTR o);
3084330844
void RapidGossipSync_free(struct LDKRapidGossipSync this_obj);
3084430845

3084530846
/**
30846-
* Instantiate a new [`RapidGossipSync`] instance
30847+
* Instantiate a new [`RapidGossipSync`] instance.
3084730848
*/
3084830849
MUST_USE_RES struct LDKRapidGossipSync RapidGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph);
3084930850

3085030851
/**
30851-
* Sync gossip data from a file
30852+
* Update network graph from binary data.
3085230853
* Returns the last sync timestamp to be used the next time rapid sync data is queried.
3085330854
*
30854-
* `network_graph`: The network graph to apply the updates to
30855-
*
30856-
* `sync_path`: Path to the file where the gossip update data is located
30855+
* `network_graph`: network graph to be updated
3085730856
*
30857+
* `update_data`: `&[u8]` binary stream that comprises the update data
3085830858
*/
30859-
MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_sync_network_graph_with_file_path(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKStr sync_path);
30859+
MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data);
3086030860

3086130861
/**
30862-
* Returns whether a rapid gossip sync has completed at least once
30862+
* Returns whether a rapid gossip sync has completed at least once.
3086330863
*/
3086430864
MUST_USE_RES bool RapidGossipSync_is_initial_sync_complete(const struct LDKRapidGossipSync *NONNULL_PTR this_arg);
3086530865

@@ -30883,16 +30883,6 @@ struct LDKGraphSyncError GraphSyncError_decode_error(struct LDKDecodeError a);
3088330883
*/
3088430884
struct LDKGraphSyncError GraphSyncError_lightning_error(struct LDKLightningError a);
3088530885

30886-
/**
30887-
* Update network graph from binary data.
30888-
* Returns the last sync timestamp to be used the next time rapid sync data is queried.
30889-
*
30890-
* `network_graph`: network graph to be updated
30891-
*
30892-
* `update_data`: `&[u8]` binary stream that comprises the update data
30893-
*/
30894-
MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data);
30895-
3089630886
#endif /* LDK_C_BINDINGS_H */
3089730887

3089830888
#include "ldk_ver.h"

lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,35 @@
66
// license as that which applies to the original source files from which this
77
// source was automatically generated.
88

9-
//! This crate exposes functionality to rapidly sync gossip data, aimed primarily at mobile
9+
//! This crate exposes client functionality to rapidly sync gossip data, aimed primarily at mobile
1010
//! devices.
1111
//!
12-
//! The server sends a compressed response containing differential gossip data. The gossip data is
13-
//! formatted compactly, omitting signatures and opportunistically incremental where previous
14-
//! channel updates are known (a mechanism that is enabled when the timestamp of the last known
15-
//! channel update is communicated). A reference server implementation can be found
16-
//! [here](https://github.com/lightningdevkit/rapid-gossip-sync-server).
12+
//! The rapid gossip sync server will provide a compressed response containing differential gossip
13+
//! data. The gossip data is formatted compactly, omitting signatures and opportunistically
14+
//! incremental where previous channel updates are known. This mechanism is enabled when the
15+
//! timestamp of the last known channel update is communicated. A reference server implementation
16+
//! can be found [on Github](https://github.com/lightningdevkit/rapid-gossip-sync-server).
1717
//!
18-
//! An example server request could look as simple as the following. Note that the first ever rapid
19-
//! sync should use `0` for `last_sync_timestamp`:
18+
//! The primary benefit of this syncing mechanism is that it allows a low-powered client to offload
19+
//! the validation of gossip signatures to a semi-trusted server. This enables the client to
20+
//! privately calculate routes for payments, and to do so much faster than requiring a full
21+
//! peer-to-peer gossip sync to complete.
22+
//!
23+
//! The server calculates its response on the basis of a client-provided `latest_seen` timestamp,
24+
//! i.e., the server will return all rapid gossip sync data it has seen after the given timestamp.
25+
//!
26+
//! # Getting Started
27+
//! Firstly, the data needs to be retrieved from the server. For example, you could use the server
28+
//! at <https://rapidsync.lightningdevkit.org> with the following request format:
2029
//!
2130
//! ```shell
2231
//! curl -o rapid_sync.lngossip https://rapidsync.lightningdevkit.org/snapshot/<last_sync_timestamp>
2332
//! ```
33+
//! Note that the first ever rapid sync should use `0` for `last_sync_timestamp`.
2434
//!
25-
//! Then, call the network processing function. In this example, we process the update by reading
26-
//! its contents from disk, which we do by calling the `sync_network_graph_with_file_path` method:
35+
//! After the gossip data snapshot has been downloaded, one of the client's graph processing
36+
//! functions needs to be called. In this example, we process the update by reading its contents
37+
//! from disk, which we do by calling [sync_network_graph_with_file_path]:
2738
//!
2839
//! ```
2940
//! use bitcoin::blockdata::constants::genesis_block;
@@ -43,21 +54,7 @@
4354
//! let rapid_sync = RapidGossipSync::new(&network_graph);
4455
//! let new_last_sync_timestamp_result = rapid_sync.sync_network_graph_with_file_path(\"./rapid_sync.lngossip\");
4556
//! ```
46-
//!
47-
//! The primary benefit this syncing mechanism provides is that given a trusted server, a
48-
//! low-powered client can offload the validation of gossip signatures. This enables a client to
49-
//! privately calculate routes for payments, and do so much faster and earlier than requiring a full
50-
//! peer-to-peer gossip sync to complete.
51-
//!
52-
//! The reason the rapid sync server requires trust is that it could provide bogus data, though at
53-
//! worst, all that would result in is a fake network topology, which wouldn't enable the server to
54-
//! steal or siphon off funds. It could, however, reduce the client's privacy by forcing all
55-
//! payments to be routed via channels the server controls.
56-
//!
57-
//! The way a server is meant to calculate this rapid gossip sync data is by using a `latest_seen`
58-
//! timestamp provided by the client. It's not included in either channel announcement or update,
59-
//! (not least due to announcements not including any timestamps at all, but only a block height)
60-
//! but rather, it's a timestamp of when the server saw a particular message.
57+
//! [sync_network_graph_with_file_path]: RapidGossipSync::sync_network_graph_with_file_path
6158
6259
use alloc::str::FromStr;
6360
use core::ffi::c_void;
@@ -73,7 +70,8 @@ pub mod processing;
7370
use lightning_rapid_gossip_sync::RapidGossipSync as nativeRapidGossipSyncImport;
7471
pub(crate) type nativeRapidGossipSync = nativeRapidGossipSyncImport<&'static lightning::routing::gossip::NetworkGraph<crate::lightning::util::logger::Logger>, crate::lightning::util::logger::Logger>;
7572

76-
/// Rapid Gossip Sync struct
73+
/// The main Rapid Gossip Sync object.
74+
///
7775
/// See [crate-level documentation] for usage.
7876
///
7977
/// [crate-level documentation]: crate
@@ -123,30 +121,29 @@ impl RapidGossipSync {
123121
ret
124122
}
125123
}
126-
/// Instantiate a new [`RapidGossipSync`] instance
124+
/// Instantiate a new [`RapidGossipSync`] instance.
127125
#[must_use]
128126
#[no_mangle]
129127
pub extern "C" fn RapidGossipSync_new(network_graph: &crate::lightning::routing::gossip::NetworkGraph) -> crate::lightning_rapid_gossip_sync::RapidGossipSync {
130128
let mut ret = lightning_rapid_gossip_sync::RapidGossipSync::new(network_graph.get_native_ref());
131129
crate::lightning_rapid_gossip_sync::RapidGossipSync { inner: ObjOps::heap_alloc(ret), is_owned: true }
132130
}
133131

134-
/// Sync gossip data from a file
132+
/// Update network graph from binary data.
135133
/// Returns the last sync timestamp to be used the next time rapid sync data is queried.
136134
///
137-
/// `network_graph`: The network graph to apply the updates to
138-
///
139-
/// `sync_path`: Path to the file where the gossip update data is located
135+
/// `network_graph`: network graph to be updated
140136
///
137+
/// `update_data`: `&[u8]` binary stream that comprises the update data
141138
#[must_use]
142139
#[no_mangle]
143-
pub extern "C" fn RapidGossipSync_sync_network_graph_with_file_path(this_arg: &crate::lightning_rapid_gossip_sync::RapidGossipSync, mut sync_path: crate::c_types::Str) -> crate::c_types::derived::CResult_u32GraphSyncErrorZ {
144-
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sync_network_graph_with_file_path(sync_path.into_str());
140+
pub extern "C" fn RapidGossipSync_update_network_graph(this_arg: &crate::lightning_rapid_gossip_sync::RapidGossipSync, mut update_data: crate::c_types::u8slice) -> crate::c_types::derived::CResult_u32GraphSyncErrorZ {
141+
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_network_graph(update_data.to_slice());
145142
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_rapid_gossip_sync::error::GraphSyncError::native_into(e) }).into() };
146143
local_ret
147144
}
148145

149-
/// Returns whether a rapid gossip sync has completed at least once
146+
/// Returns whether a rapid gossip sync has completed at least once.
150147
#[must_use]
151148
#[no_mangle]
152149
pub extern "C" fn RapidGossipSync_is_initial_sync_complete(this_arg: &crate::lightning_rapid_gossip_sync::RapidGossipSync) -> bool {

lightning-c-bindings/src/lightning_rapid_gossip_sync/processing.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,3 @@ use crate::c_types::*;
1616
#[cfg(feature="no-std")]
1717
use alloc::{vec::Vec, boxed::Box};
1818

19-
/// Update network graph from binary data.
20-
/// Returns the last sync timestamp to be used the next time rapid sync data is queried.
21-
///
22-
/// `network_graph`: network graph to be updated
23-
///
24-
/// `update_data`: `&[u8]` binary stream that comprises the update data
25-
#[must_use]
26-
#[no_mangle]
27-
pub extern "C" fn RapidGossipSync_update_network_graph(this_arg: &crate::lightning_rapid_gossip_sync::RapidGossipSync, mut update_data: crate::c_types::u8slice) -> crate::c_types::derived::CResult_u32GraphSyncErrorZ {
28-
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_network_graph(update_data.to_slice());
29-
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_rapid_gossip_sync::error::GraphSyncError::native_into(e) }).into() };
30-
local_ret
31-
}
32-

0 commit comments

Comments
 (0)