mobile: Add ServiceStatus for retrieving current runtime status of lnd

Used for checking whether lnd is started or not.
ServiceStatus can also be used to determine when lnd has shut down, since
`stopDaemon` returns immediately and does not wait for the gRPC servers
to be fully closed.
This commit is contained in:
Hampus Sjöberg 2020-09-04 15:03:07 +02:00
parent 14a01eb84f
commit aca307f05f
No known key found for this signature in database
GPG key ID: BDF8385AEAB2B2A1

View file

@ -156,3 +156,18 @@ func Start(extraArgs string, rpcReady Callback) {
rpcReady.OnResponse([]byte{})
}()
}
type LndStatusCallback interface {
OnResponse(lndStarted int32)
}
// ServiceStatus returns 1 if lnd has started up successfully, allowing the
// caller to interact with the in-memory gRPC servers. If 0 is returned, the
// caller should invoke `Start` to initialize lnd.
//
// ServiceStatus can also be used to determine when lnd has shut down, since
// `stopDaemon` returns immediately and does not wait for the gRPC servers to be
// fully closed.
func ServiceStatus(callback LndStatusCallback) {
callback.OnResponse(atomic.LoadInt32(&lndStarted))
}