Skip to content

Commit 67541ae

Browse files
committed
fix spacing
1 parent 2b9cd91 commit 67541ae

File tree

9 files changed

+46
-42
lines changed

9 files changed

+46
-42
lines changed

c-bindings-gen/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ fn print_method_params<W: std::io::Write>(w: &mut W, sig: &syn::Signature, assoc
7171
syn::FnArg::Receiver(recv) => {
7272
if !recv.attrs.is_empty() || recv.reference.is_none() { unimplemented!(); }
7373
if recv.reference.as_ref().unwrap().1.is_some() { unimplemented!(); }
74-
write!(w, "this_arg: {}{} {}",
75-
if self_ptr && recv.mutability.is_some() { "*" } else if self_ptr { "*const " } else { "&" },
76-
if recv.mutability.is_some() { "mut " } else { "" }, this_param).unwrap();
74+
write!(w, "this_arg: {}{}",
75+
match (self_ptr, recv.mutability.is_some()) {
76+
(true, true) => "*mut ",
77+
(true, false) => "*const ",
78+
(false, true) => "&mut ",
79+
(false, false) => "&",
80+
}, this_param).unwrap();
7781
assert!(first_arg);
7882
first_arg = false;
7983
},

lightning-c-bindings/src/chain/chaininterface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl ChainError {
5050
pub struct BroadcasterInterface {
5151
pub this_arg: *mut c_void,
5252
/// " Sends a transaction out to (hopefully) be mined."
53-
pub broadcast_transaction: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction),
53+
pub broadcast_transaction: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction),
5454
}
5555
unsafe impl Sync for BroadcasterInterface {}
5656
unsafe impl Send for BroadcasterInterface {}
@@ -118,7 +118,7 @@ pub struct FeeEstimator {
118118
/// " This translates to:"
119119
/// " * satoshis-per-byte * 250"
120120
/// " * ceil(satoshis-per-kbyte / 4)"
121-
pub get_est_sat_per_1000_weight: extern "C" fn (this_arg: *const c_void, confirmation_target: ConfirmationTarget) -> u64,
121+
pub get_est_sat_per_1000_weight: extern "C" fn (this_arg: *const c_void, confirmation_target: ConfirmationTarget) -> u64,
122122
}
123123
unsafe impl Sync for FeeEstimator {}
124124
unsafe impl Send for FeeEstimator {}

lightning-c-bindings/src/chain/keysinterface.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,17 @@ impl std::ops::Deref for ChannelKeys {
141141
pub struct KeysInterface {
142142
pub this_arg: *mut c_void,
143143
/// " Get node secret key (aka node_id or network_key)"
144-
pub get_node_secret: extern "C" fn (this_arg: *const c_void) -> crate::c_types::SecretKey,
144+
pub get_node_secret: extern "C" fn (this_arg: *const c_void) -> crate::c_types::SecretKey,
145145
/// " Get destination redeemScript to encumber static protocol exit points."
146-
pub get_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::Script,
146+
pub get_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::Script,
147147
/// " Get shutdown_pubkey to use as PublicKey at channel closure"
148-
pub get_shutdown_pubkey: extern "C" fn (this_arg: *const c_void) -> crate::c_types::PublicKey,
148+
pub get_shutdown_pubkey: extern "C" fn (this_arg: *const c_void) -> crate::c_types::PublicKey,
149149
//XXX: Need to export get_channel_keys
150150
//XXX: Need to export get_onion_rand
151151
/// " Get a unique temporary channel id. Channels will be referred to by this until the funding"
152152
/// " transaction is created, at which point they will use the outpoint in the funding"
153153
/// " transaction."
154-
pub get_channel_id: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes,
154+
pub get_channel_id: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes,
155155
}
156156
unsafe impl Send for KeysInterface {}
157157
unsafe impl Sync for KeysInterface {}

lightning-c-bindings/src/chain/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub extern "C" fn OutPoint_new(txid_arg: [u8; 32], index_arg: u16) -> OutPoint {
4545
}
4646
/// " Convert an `OutPoint` to a lightning channel id."
4747
#[no_mangle]
48-
pub extern "C" fn OutPoint_to_channel_id(this_arg: & OutPoint) -> crate::c_types::ThirtyTwoBytes {
48+
pub extern "C" fn OutPoint_to_channel_id(this_arg: &OutPoint) -> crate::c_types::ThirtyTwoBytes {
4949
crate::c_types::ThirtyTwoBytes { data: unsafe { &*this_arg.inner }.to_channel_id() }
5050
}
5151

lightning-c-bindings/src/ln/channelmanager.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ pub extern "C" fn ChannelManager_new(network: crate::bitcoin::network::Network,
207207
/// " Force closes a channel, immediately broadcasting the latest local commitment transaction to"
208208
/// " the chain and rejecting new HTLCs on the given channel."
209209
#[no_mangle]
210-
pub extern "C" fn ChannelManager_force_close_channel(this_arg: & ChannelManager, channel_id: *const [u8; 32]) {
210+
pub extern "C" fn ChannelManager_force_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) {
211211
unsafe { &*this_arg.inner }.force_close_channel(unsafe { &*channel_id})
212212
}
213213

214214
/// " Force close all channels, immediately broadcasting the latest local commitment transaction"
215215
/// " for each to the chain and rejecting new HTLCs on each."
216216
#[no_mangle]
217-
pub extern "C" fn ChannelManager_force_close_all_channels(this_arg: & ChannelManager) {
217+
pub extern "C" fn ChannelManager_force_close_all_channels(this_arg: &ChannelManager) {
218218
unsafe { &*this_arg.inner }.force_close_all_channels()
219219
}
220220

@@ -223,7 +223,7 @@ pub extern "C" fn ChannelManager_force_close_all_channels(this_arg: & ChannelMan
223223
/// " Should only really ever be called in response to a PendingHTLCsForwardable event."
224224
/// " Will likely generate further events."
225225
#[no_mangle]
226-
pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: & ChannelManager) {
226+
pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: &ChannelManager) {
227227
unsafe { &*this_arg.inner }.process_pending_htlc_forwards()
228228
}
229229

@@ -233,13 +233,13 @@ pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: & Chann
233233
/// ""
234234
/// " This method handles all the details, and must be called roughly once per minute."
235235
#[no_mangle]
236-
pub extern "C" fn ChannelManager_timer_chan_freshness_every_min(this_arg: & ChannelManager) {
236+
pub extern "C" fn ChannelManager_timer_chan_freshness_every_min(this_arg: &ChannelManager) {
237237
unsafe { &*this_arg.inner }.timer_chan_freshness_every_min()
238238
}
239239

240240
/// " Gets the node_id held by this ChannelManager"
241241
#[no_mangle]
242-
pub extern "C" fn ChannelManager_get_our_node_id(this_arg: & ChannelManager) -> crate::c_types::PublicKey {
242+
pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &ChannelManager) -> crate::c_types::PublicKey {
243243
crate::c_types::PublicKey::from_rust(&unsafe { &*this_arg.inner }.get_our_node_id())
244244
}
245245

lightning-c-bindings/src/ln/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl std::ops::Deref for ManyChannelMonitor {
234234
/// " Gets the update_id from the latest ChannelMonitorUpdate which was applied to this"
235235
/// " ChannelMonitor."
236236
#[no_mangle]
237-
pub extern "C" fn ChannelMonitor_get_latest_update_id(this_arg: & ChannelMonitor) -> u64 {
237+
pub extern "C" fn ChannelMonitor_get_latest_update_id(this_arg: &ChannelMonitor) -> u64 {
238238
unsafe { &*this_arg.inner }.get_latest_update_id()
239239
}
240240

lightning-c-bindings/src/ln/msgs.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -520,46 +520,46 @@ pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) {
520520
pub struct ChannelMessageHandler {
521521
pub this_arg: *mut c_void,
522522
/// " Handle an incoming open_channel message from the given peer."
523-
pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::ln::features::InitFeatures, msg: &OpenChannel),
523+
pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::ln::features::InitFeatures, msg: &OpenChannel),
524524
/// " Handle an incoming accept_channel message from the given peer."
525-
pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::ln::features::InitFeatures, msg: &AcceptChannel),
525+
pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, their_features: crate::ln::features::InitFeatures, msg: &AcceptChannel),
526526
/// " Handle an incoming funding_created message from the given peer."
527-
pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &FundingCreated),
527+
pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &FundingCreated),
528528
/// " Handle an incoming funding_signed message from the given peer."
529-
pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &FundingSigned),
529+
pub handle_funding_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &FundingSigned),
530530
/// " Handle an incoming funding_locked message from the given peer."
531-
pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &FundingLocked),
531+
pub handle_funding_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &FundingLocked),
532532
/// " Handle an incoming shutdown message from the given peer."
533-
pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &Shutdown),
533+
pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &Shutdown),
534534
/// " Handle an incoming closing_signed message from the given peer."
535-
pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &ClosingSigned),
535+
pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &ClosingSigned),
536536
/// " Handle an incoming update_add_htlc message from the given peer."
537-
pub handle_update_add_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &UpdateAddHTLC),
537+
pub handle_update_add_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &UpdateAddHTLC),
538538
/// " Handle an incoming update_fulfill_htlc message from the given peer."
539-
pub handle_update_fulfill_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &UpdateFulfillHTLC),
539+
pub handle_update_fulfill_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &UpdateFulfillHTLC),
540540
/// " Handle an incoming update_fail_htlc message from the given peer."
541-
pub handle_update_fail_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &UpdateFailHTLC),
541+
pub handle_update_fail_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &UpdateFailHTLC),
542542
/// " Handle an incoming update_fail_malformed_htlc message from the given peer."
543-
pub handle_update_fail_malformed_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &UpdateFailMalformedHTLC),
543+
pub handle_update_fail_malformed_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &UpdateFailMalformedHTLC),
544544
/// " Handle an incoming commitment_signed message from the given peer."
545-
pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &CommitmentSigned),
545+
pub handle_commitment_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &CommitmentSigned),
546546
/// " Handle an incoming revoke_and_ack message from the given peer."
547-
pub handle_revoke_and_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &RevokeAndACK),
547+
pub handle_revoke_and_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &RevokeAndACK),
548548
/// " Handle an incoming update_fee message from the given peer."
549-
pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &UpdateFee),
549+
pub handle_update_fee: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &UpdateFee),
550550
/// " Handle an incoming announcement_signatures message from the given peer."
551-
pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &AnnouncementSignatures),
551+
pub handle_announcement_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &AnnouncementSignatures),
552552
/// " Indicates a connection to the peer failed/an existing connection was lost. If no connection"
553553
/// " is believed to be possible in the future (eg they're sending us messages we don't"
554554
/// " understand or indicate they require unknown feature bits), no_connection_possible is set"
555555
/// " and any outstanding channels should be failed."
556-
pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
556+
pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, no_connection_possible: bool),
557557
/// " Handle a peer reconnecting, possibly generating channel_reestablish message(s)."
558-
pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &Init),
558+
pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &Init),
559559
/// " Handle an incoming channel_reestablish message from the given peer."
560-
pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &ChannelReestablish),
560+
pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &ChannelReestablish),
561561
/// " Handle an incoming error message from the given peer."
562-
pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &ErrorMessage),
562+
pub handle_error: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &ErrorMessage),
563563
pub MessageSendEventsProvider: crate::util::events::MessageSendEventsProvider,
564564
}
565565
impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler {
@@ -650,7 +650,7 @@ pub struct RoutingMessageHandler {
650650
//XXX: Need to export get_next_channel_announcements
651651
//XXX: Need to export get_next_node_announcements
652652
/// " Returns whether a full sync should be requested from a peer."
653-
pub should_request_full_sync: extern "C" fn (this_arg: *const c_void, node_id: crate::c_types::PublicKey) -> bool,
653+
pub should_request_full_sync: extern "C" fn (this_arg: *const c_void, node_id: crate::c_types::PublicKey) -> bool,
654654
}
655655
unsafe impl Send for RoutingMessageHandler {}
656656
unsafe impl Sync for RoutingMessageHandler {}

lightning-c-bindings/src/ln/peer_handler.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ pub struct SocketDescriptor {
8787
/// " events should be paused to prevent DoS in the send buffer), resume_read may be set"
8888
/// " indicating that read events on this descriptor should resume. A resume_read of false does"
8989
/// " *not* imply that further read events should be paused."
90-
pub send_data: extern "C" fn (this_arg: *mut c_void, data: crate::c_types::u8slice, resume_read: bool) -> usize,
90+
pub send_data: extern "C" fn (this_arg: *mut c_void, data: crate::c_types::u8slice, resume_read: bool) -> usize,
9191
/// " Disconnect the socket pointed to by this SocketDescriptor. Once this function returns, no"
9292
/// " more calls to write_buffer_space_avail, read_event or socket_disconnected may be made with"
9393
/// " this descriptor. No socket_disconnected call should be generated as a result of this call,"
9494
/// " though races may occur whereby disconnect_socket is called after a call to"
9595
/// " socket_disconnected but prior to socket_disconnected returning."
96-
pub disconnect_socket: extern "C" fn (this_arg: *mut c_void),
96+
pub disconnect_socket: extern "C" fn (this_arg: *mut c_void),
9797
pub eq: extern "C" fn (this_arg: *const c_void, other_arg: *const c_void) -> bool,
9898
pub hash: extern "C" fn (this_arg: *const c_void) -> u64,
9999
}
@@ -177,7 +177,7 @@ pub extern "C" fn PeerManager_new(message_handler: MessageHandler, our_node_secr
177177
/// " response messages as well as messages generated by calls to handler functions directly (eg"
178178
/// " functions like ChannelManager::process_pending_htlc_forward or send_payment)."
179179
#[no_mangle]
180-
pub extern "C" fn PeerManager_process_events(this_arg: & PeerManager) {
180+
pub extern "C" fn PeerManager_process_events(this_arg: &PeerManager) {
181181
unsafe { &*this_arg.inner }.process_events()
182182
}
183183

@@ -190,15 +190,15 @@ pub extern "C" fn PeerManager_process_events(this_arg: & PeerManager) {
190190
/// ""
191191
/// " Panics if the descriptor was not previously registered in a successful new_*_connection event."
192192
#[no_mangle]
193-
pub extern "C" fn PeerManager_socket_disconnected(this_arg: & PeerManager, descriptor: & SocketDescriptor) {
193+
pub extern "C" fn PeerManager_socket_disconnected(this_arg: &PeerManager, descriptor: & SocketDescriptor) {
194194
unsafe { &*this_arg.inner }.socket_disconnected(descriptor)
195195
}
196196

197197
/// " This function should be called roughly once every 30 seconds."
198198
/// " It will send pings to each peer and disconnect those which did not respond to the last round of pings."
199199
/// " Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues!"
200200
#[no_mangle]
201-
pub extern "C" fn PeerManager_timer_tick_occured(this_arg: & PeerManager) {
201+
pub extern "C" fn PeerManager_timer_tick_occured(this_arg: &PeerManager) {
202202
unsafe { &*this_arg.inner }.timer_tick_occured()
203203
}
204204

lightning-c-bindings/src/util/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub extern "C" fn Level_max() -> Level {
6060
pub struct Logger {
6161
pub this_arg: *mut c_void,
6262
/// " Logs the `Record`"
63-
pub log: extern "C" fn (this_arg: *const c_void, record: *const std::os::raw::c_char),
63+
pub log: extern "C" fn (this_arg: *const c_void, record: *const std::os::raw::c_char),
6464
}
6565
unsafe impl Sync for Logger {}
6666
unsafe impl Send for Logger {}

0 commit comments

Comments
 (0)