-
Notifications
You must be signed in to change notification settings - Fork 91
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
Introduce status
method allowing to query the Node
's status
#272
Conversation
e317d13
to
4dd7ea7
Compare
#[derive(Debug, Clone, PartialEq, Eq)] | ||
pub struct BestBlock { |
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 only needed because LDK's struct doesn't derive Debug
?
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.
It not deriving Debug
is one reason, but more importantly it doesn't expose the block_hash
/height
fields directly, only via methods. This is fine in Rust, but for our bindings it would mean that we'd need to expose it as an interface
rather than a dictionary
, in turn meaning NodeStatus
would need to hold an Arc<BestBlock>
, etc.
So it's easiest here to introduce a newtype that's compliant with the limitations of our bindings generator.
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.
I now opened lightningdevkit/rust-lightning#2923, but would still prefer to go ahead with the newtype wrapper in this PR and switch to using the refactored upstream version in #243 to allow this PR to land independently.
pub latest_wallet_sync_timestamp: Option<u64>, | ||
/// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced | ||
/// our on-chain wallet to the chain tip. | ||
/// | ||
/// Will be `None` if the wallet hasn't been synced since the [`Node`] was initialized. | ||
pub latest_onchain_wallet_sync_timestamp: Option<u64>, | ||
/// The timestamp, in seconds since start of the UNIX epoch, when we last successfully update | ||
/// our fee rate cache. | ||
/// | ||
/// Will be `None` if the cache hasn't been updated since the [`Node`] was initialized. | ||
pub latest_fee_rate_cache_update_timestamp: Option<u64>, | ||
/// The timestamp, in seconds since start of the UNIX epoch, when the last rapid gossip sync | ||
/// (RGS) snapshot we successfully applied was generated. | ||
/// | ||
/// Will be `None` if RGS isn't configured or the snapshot hasn't been updated since the [`Node`] was initialized. | ||
pub latest_rgs_snapshot_timestamp: Option<u64>, | ||
/// The timestamp, in seconds since start of the UNIX epoch, when we last broadcasted a node | ||
/// announcement. | ||
/// | ||
/// Will be `None` if we have no public channels or we haven't broadcasted since the [`Node`] was initialized. | ||
pub latest_node_announcement_broadcast_timestamp: Option<u64>, |
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.
Would it make sense to use Duration
for these?
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.
No, if anything we'd want to make them SystemTime
(or chrono::DateTime
for that matter), but we'll need to convert to timestamps for the bindings anyways. Same goes for the upcoming inclusion of a last_changed
timestamp in the PaymentDetails
, where an additional blocker is that we don't implement Readable
/Writeable
for SystemTime
upstream.
So I currently lean towards using UNIX timestamps in the API as everything else seems to complicate things further?
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.
Hmm... Duration
is a timestamp when interpreted as relative to the Unix epoch. It just gives you more precision than u64
seconds and may be more useful interface to work with. But fair enough regarding bindings.
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.
Ah, yeah, I agree in Rust a Duration
would be preferable and I see that we even implement Writeable
/Readable
for it. However, in the bindings it would be weird because I can either translate it to a u64
where it becomes unclear what unit to use: in this context seconds would make sense, but otherwise we might want to translate it to a u64
representing nanos or so. The other way would to expose it as an interface Duration
that mirrors the Rust type. However, in Kotlin/Swift/Python introducing a general Duration
type wouldn't make a lot of sense. Technically Uniffi would have the capability to translate a value on the bindings side once more, which would allow us to use the idiomatic Swift/Kotlin/Python types. I'll think about it some more. Good thing is that these fields aren't persisted, i.e., until we do we can easily reconsider/improve them.
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.
LGTM. Seems like you'll need a rebase.
.. we replace the simple `is_running` with a more verbose `status` method returning a `NodeStatus` struct, giving more information on syncing states etc.
4dd7ea7
to
b052f15
Compare
Rebase without further changes. |
Fixes #127.