-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[0.0.123-bindings] Bindings changes for 0.0.123 #3062
[0.0.123-bindings] Bindings changes for 0.0.123 #3062
Conversation
Now that `ChannelId` has useful constructors and methods we need to start exposing it to bindings users rather than relying on using `[u8; 32]`.
This avoids the bindings trying to figure out what a `lightning::prelude::Vec` is rather than matching it as a `Vec`.
`Amount` is less than two pointers long, so there's no reason it shouldn't be `Copy`. Further, because its an enum, bindings can't map a reference to it in an `Option`. Thus, here, we simply make it `Copy` and return it in `Option`s rather than a reference to it.
62fce5a
to
7ac5b46
Compare
This is required for bindings as passing types from Rust to GC'd languages can't map the concept of a type that has a lifetime of the called function but instead needs to clone for safety.
This is required for GC'd languages which need to be able to clone in order to pass owned objects to Rust.
7ac5b46
to
3ef8211
Compare
This matches our normal API semantics and allows, for example, `Arc`s to `EntropySource`s.
3ef8211
to
e7e551c
Compare
@@ -34,6 +34,8 @@ use core::ops::Deref; | |||
|
|||
use crate::prelude::*; | |||
|
|||
use core::ops::Deref; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little confused about 4cab9cb. The message doesn't seem to match the change and then it is reverted in the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh oops its just an old commit that didn't get dropped during the rebase, dropped.
/// | ||
/// Thus, this method should be polled regularly to detect messages await such a direct | ||
/// connection. | ||
fn get_and_clear_connections_needed(&self) -> Vec<(PublicKey, Vec<SocketAddress>)>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have this return Vec<Event>
given #2973 expands the type of events returned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, indeed, but we've done this for a release already so I'd kinda rather we just do it in the next one?
pub fn as_array(&self) -> &[u8; PUBLIC_KEY_SIZE] { | ||
pub fn as_array(&self) -> &[u8; 33] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? Seems unrelated to the rest of the commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the bindings doesn't know how to parse constants out of CONSTANTS :/
While there's not really much harm in requiring a `Clone`able reference (they almost always are), it does make our bindings struggle a bit as they don't support multi-trait bounds (as it would require synthesizing a new C trait, which the bindings don't do automatically). Luckily, there's really no reason for it, and we can just call the `DefaultMessageRouter` directly when we want to route a message.
...as the bindings generation does not currently have the ability to map a reference to a `NodeId` inside a tuple.
Bindings can't handle references in return types, so reduce the visibility to pub(crate).
The bindings currently get confused by the implicit `Sign` type, so we temporarily remove it on the `impl` here.
Re-exports in Rust make `use` statements a little shorter, but for otherwise don't materially change a crate's API. Sadly, the C bindings generator currently can't figure out re-exports, but it also exports everything into one global namespace, so it doesn't matter much anyway.
Having struct fields with references to other structs is tough in our bindings logic, but even worse if the fields are in an enum. Its simplest to just take the clone penalty here.
The scorer currently relies on an associated type for the fee parameters. This isn't supportable at all in bindings, and for lack of a better option we simply hard-code the parameter for all scorers to `ProbabilisticScoringFeeParameters`.
These are not expressible in C/most languages, and thus must be hidden.
Rather than `ChannelMonitor` only being clonable when the signer is clonable, we require all signers to be clonable and then make all `ChannelMonitor`s clonable.
`OnionMessageHandler`s are expected to regularly release a set of nodes which we need to directly connect to to deliver onion messages. In order to do so, they currently extend `EventsProvider`, returning that set as `Event::ConnectionNeeded`s. While this works fine in Rust, the `EventsProvider` interface doesn't map well in bindings due to it taking a flexible trait impl as a method argument. Instead, here, we convert `OnionMessageHandler` to include a single function which returns nodes in the form of a `node_id` and `Vec<SocketAddress>`. This is a bit simpler, if less flexible, API, and while largely equivalent, is easier to map in bindings.
As we cannot express slices without inner references in bindings wrappers.
...as we currently struggle with `AChannelManager` on it
e7e551c
to
4f8f9b4
Compare
Dropped commits that totaled empty, no diff. |
9b523d9
into
lightningdevkit:0.0.123-bindings
Bindings specific changes, including #3061.