-
Notifications
You must be signed in to change notification settings - Fork 385
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
Implement FromStr
for NetAddress
#2056
Comments
May also be nice to impl |
hey |
@tnull how would you identify the input string(to which enum property it should be assigned)? we can do something like this where key is one of the enum props fn from_str(s: &str) -> Result<Self, Self::Err> {
let key = s.split(":")[0]
let value = s.split(":")[1]
} we can then use match statement match key {
"ipv4": ...,
"ipv6": ...,
"hostname": ...,
} |
hey @tnull , I would like to do it. Please assign me this issue. |
I think we should first try to parse the IPv4/IPv6 cases and then fall back on |
I'm not sure its that straightforward? If you have a hostname, we probably just want to include the singular hostname variant, but that may be a bit surprising to users (which is a more general criticism of |
Can you elaborate on what the specific use-cases is here - are we trying to convert some user-provided configfile-read value to a |
Basically, yes. I want to enable name resolution support in LDK Node and would love to reuse |
@jbesraa Still interested in picking this up? |
yes. I was just waiting for the discussion to come into a conclusion.. can u please review the comment above with the code snippet to validate my thoughts..? |
Great! Yes, as said above the approach basically seems valid. You probably first want to try parse the string into a |
I don't think we want to try to parse into a socket address at all - if we get a hostname, generally we want to store/announce/etc that hostname and only do the resolution when we actually go to connect. Thus, maybe instead we consider implementing |
Ah, I see your point, as Also implementing |
I still don't really see why we'd want to do that? If we get a hostname, we should store + announce it as a hostname. I don't see why we should do resolution of the hostname except considering backwards compat of other nodes not reading the hostname address type, but I think that's increasingly less of a concern these days. |
Agreed. But how do we know the string we got is a hostname, if we don't try to parse it to
To clarify: I'm not saying we should resolve the hostname during |
Ah! Okay, yes, we're on the same page, we should try to parse it as an address, obviously, but not try to resolve the hostname. |
@jbesraa Any news on this? Would be great to get it into the next release. |
Hey |
Great, thanks! The release is scheduled for ~next week or so, let's see how this goes. No worries if it doesn't land in time, as worst case I can still pull it in via a master-branch dependency for now. |
I think the 115 release will probably be in three or four weeks. We're trying to get all the major PRs up for review this week, but minor things like this can probably slip in after that deadline. |
I created initial commit here jbesraa@20a2482 |
Great to hear, feel free to open a draft PR! |
IIUC |
Huh, hadn't realized ln_types exists, does it make sense to move some of the |
WTF, I totally remember mentioning it to you but I can't find the conversation! It could possibly make sense to collaborate more and I'm totally open to handing over the crate. Regarding integrations, IDK what your policy is, here are some reasons I added them:
I would personally at least want to continue supporting |
Heh, my personal view is generally "don't bother doing any integration with anything in the rust ecosystem cause most of it doesn't care about MSRV and trying to do split MSRV across dependencies is a pain, so let downstream folks do their own integrations if they want" :). Eg we recently had to rip out serde stuff because their MSRV policy is "YOLO", which just isn't practical :/. Stuff that actually has a reasonable MSRV we could probably do, but I honestly just kinda hate the "rust ecosystem" and don't like bothering to interact... |
Don't you find |
At least tokio maintains MSRVs for a given minor release, so you at least know you'll get bugfixes at your given MSRV as long as its an LTS release. serde I don't really think its worth it, at least for us, because we already have a serialization framework (namely the lightning-native one) so we just re-use that everywhere rather than trying to use something like serde (and forgetting to apply our preconditions when reading :p). |
I see why it's not useful for most types. I find "interface types" still important:
These occur in human-readable interfaces, RPCs, configuration files... |
Why? In human-readable interfaces, RPCs and configuration files you're probably JSON'ing or hex'ing, or doing something actually human readable.... not using serde (though you may use serde's JSON decoder, but probably not hex). Doubly so for something like invoice where there's a pre-defined human-readable/string encoding. |
Indeed, that's why having serde impls (de)serialize as strings is important. |
|
The problem is that defining custom serialization module and slapping |
Right, for all the types you listed we want something for tostring that isn't naive serde, though, and in lightning in general we often have custom serialization we have to use anyway. |
I agree it would be nice to have such types as a sub-crate eventually. FWIW, I'm already introducing some of these type wrappers around |
Just want to +1 @Kixunil above; there should be
Even if you personally dislike the Rust ecosystem, the fact that most Rust + Bitcoin ecosystem libraries and most of LDK's downstream Rust users use A quick list of crates / LDK projects that integrate with serde: Here's a list of LDK types we serialize in some way or another which we've already newtyped to get a
Granted, this is a short list, and most LDK types don't need it. The logic-heavy / security-critical types like
|
It would be nice to allow for the parsing of
NetAddress
es fromString
, as it's likely needed by users ofNetAddress
, and currently they'd have to create a newtype to do it.It's really straightforward as we can lean on
to_socket_addrs
and, in case this fails, onHostname::try_from
.The text was updated successfully, but these errors were encountered: