protected override async Task EnsureDaemonsSynchedAsync() { var syncPendingNotificationShown = false; while (true) { var request = new GetBlockTemplateRequest { WalletAddress = poolConfig.Address, ReserveSize = MoneroConstants.ReserveSize }; var responses = await daemon.ExecuteCmdAllAsync <GetBlockTemplateResponse>( MC.GetBlockTemplate, request); var isSynched = responses.All(x => x.Error == null || x.Error.Code != -9); if (isSynched) { logger.Info(() => $"[{LogCat}] All daemons synched with blockchain"); break; } if (!syncPendingNotificationShown) { logger.Info(() => $"[{LogCat}] Daemons still syncing with network. Manager will be started once synced"); syncPendingNotificationShown = true; } await ShowDaemonSyncProgressAsync(); // delay retry by 5s await Task.Delay(5000); } }
protected override async Task EnsureDaemonSynchedAsync() { var request = new GetBlockTemplateRequest { WalletAddress = PoolContext.PoolAddress, ReserveSize = MoneroConstants.ReserveSize }; while (true) // loop until sync is complete. { var blockTemplateResponse = await PoolContext.Daemon.ExecuteCommandAsync <GetBlockTemplateResponse>(MoneroRpcCommands.GetBlockTemplate, request); var isSynched = blockTemplateResponse.Error == null || blockTemplateResponse.Error.Code != -9; // is daemon synced to network? if (isSynched) // break out of the loop once synched. { break; } var infoResponse = await PoolContext.Daemon.ExecuteCommandAsync <GetInfoResponse>(MoneroRpcCommands.GetInfo); // getinfo. var currentHeight = infoResponse.Response.Height; var totalBlocks = infoResponse.Response.TargetHeight; var percent = (double)currentHeight / totalBlocks * 100; _logger.Information($"waiting for blockchain sync [{percent:0.00}%].."); await Task.Delay(5000); // stay awhile and listen! } _logger.Information("blockchain is synched to network.."); }
private async Task <RpcResponse <GetBlockTemplateResponse> > GetBlockTemplateAsync(CancellationToken ct) { var request = new GetBlockTemplateRequest { WalletAddress = poolConfig.Address, ReserveSize = CryptonoteConstants.ReserveSize }; return(await rpc.ExecuteAsync <GetBlockTemplateResponse>(logger, CryptonoteCommands.GetBlockTemplate, ct, request)); }
private async Task <DaemonResponse <GetBlockTemplateResponse> > GetBlockTemplateAsync() { var request = new GetBlockTemplateRequest { WalletAddress = poolConfig.Address, ReserveSize = MoneroConstants.ReserveSize }; return(await daemon.ExecuteCmdAnyAsync <GetBlockTemplateResponse>(MC.GetBlockTemplate, request)); }
private async Task <DaemonResponse <GetBlockTemplateResponse> > GetBlockTemplateAsync() { logger.LogInvoke(); var request = new GetBlockTemplateRequest { WalletAddress = poolConfig.Address, ReserveSize = CryptonoteConstants.ReserveSize }; return(await daemon.ExecuteCmdAnyAsync <GetBlockTemplateResponse>(logger, CryptonoteCommands.GetBlockTemplate, request)); }
protected override async Task <MoneroJob> UpdateJob() { try { // cook our getblocktemplate() request. var request = new GetBlockTemplateRequest { WalletAddress = PoolContext.PoolAddress, ReserveSize = MoneroConstants.ReserveSize }; // call getblocktemplate() from daemon. var response = await PoolContext.Daemon.ExecuteCommandAsync <GetBlockTemplateResponse>(MoneroRpcCommands.GetBlockTemplate, request); // make sure we are free of errors. if (response.Error != null) { _logger.Error($"New job creation failed as daemon responded with [{response.Error.Code}] {response.Error.Message}"); } // get the response. var blockTemplate = response.Response; // check if we really got a new blocktemplate (for a new block). var gotNewBlockTemplate = (CurrentJob == null || CurrentJob.BlockTemplate.Height < blockTemplate.Height); // if we got a new block there, create a new job for it then. if (gotNewBlockTemplate) { var jobId = _jobCounter.GetNext(); // create a new job id. var job = new MoneroJob(jobId, blockTemplate, instanceId); // cook the job. CurrentJob = job; // set the current job. return(job); } return(null); } catch (Exception e) { _logger.Error(e, "Error querying for a new job."); return(null); } }
public Task <GetBlockHeaderByHashResponse> GetBlockHeaderByHash(GetBlockTemplateRequest request, CancellationToken cts = default(CancellationToken)) { return(SendCommandAsync <GetBlockTemplateRequest, GetBlockHeaderByHashResponse>("get_block_header_by_hash", request, cts)); }
public Task <GetBlockTemplateResponse> GetBlockTemplate(GetBlockTemplateRequest request, CancellationToken cts = default(CancellationToken)) { return(SendCommandAsync <GetBlockTemplateRequest, GetBlockTemplateResponse>("get_block_template", request, cts)); }