connect method
Asynchronous method to connect to the Haveno daemon.
Takes host
, port
, and password
as parameters to initialize
the connection. If already connected, it will return early.
Implementation
Future<void> connect(String host, int port, String password) async {
if (isConnected) {
print(
"We tried to connect to the Haveno daemon a second time, if you need to reconnect you must disconnect first then run .connect()");
return; // Already connected, do nothing.
}
_host = host;
_port = port;
_password = password;
// Initializing the gRPC channel
_channel = ClientChannel(
host,
port: port,
options: ChannelOptions(
credentials: const ChannelCredentials.insecure(),
codecRegistry: CodecRegistry(codecs: const [GzipCodec(), IdentityCodec()]),
connectionTimeout: const Duration(seconds: 30),
idleTimeout: const Duration(minutes: 10),
),
);
// Initialize clients for each gRPC service
_initializeClients();
await _checkConnection();
_connectionCompleter.complete();
}