fetchVersion method
Fetches the current version of the Haveno daemon from the gRPC server.
This method sends a GetVersionRequest to the Haveno gRPC server and retrieves
the current version of the daemon, storing it in _version
. If the Haveno client
is not connected, a DaemonNotConnectedException is thrown.
Example:
final fetchedVersion = await versionClient.fetchVersion();
print(fetchedVersion); // Outputs the current daemon version
Returns:
- A
Future
containing the fetched version as aString
. null
if an error occurs during the fetch operation.
Throws:
- DaemonNotConnectedException if the Haveno client is not connected to the gRPC server.
Implementation
Future<String?> fetchVersion() async {
// Check if the Haveno client is connected to the gRPC server.
if (!havenoChannel.isConnected) {
throw DaemonNotConnectedException();
}
try {
// Send the GetVersionRequest to the Haveno gRPC server.
final versionReply =
await havenoChannel.versionClient!.getVersion(GetVersionRequest());
// Return the version.
return versionReply.version;
} on GrpcError catch (e) {
// Handle gRPC errors using the GrpcErrorHandler mixin.
handleGrpcError(e);
}
// Return null if an error occurs.
return null;
}