public async Task <Responses.MinerSettings> SetMinerSettingsAsync(string poolId, string address,
                                                                          [FromBody] Responses.MinerSettings settings)
        {
            var pool = GetPool(poolId);

            if (string.IsNullOrEmpty(address))
            {
                throw new ApiException("Invalid or missing miner address", HttpStatusCode.NotFound);
            }

            if (settings == null)
            {
                throw new ApiException("Invalid or missing settings", HttpStatusCode.BadRequest);
            }

            // map settings
            var mapped = mapper.Map <Persistence.Model.MinerSettings>(settings);

            mapped.PoolId  = pool.Id;
            mapped.Address = address;

            var result = await cf.RunTx((con, tx) => minerRepo.UpdateSettings(con, tx, mapped));

            return(mapper.Map <Responses.MinerSettings>(result));
        }
    public async Task <Responses.MinerSettings> SetMinerSettingsAsync(string poolId, string address,
                                                                      [FromBody] Responses.MinerSettings settings)
    {
        var pool = GetPool(poolId);

        if (string.IsNullOrEmpty(address))
        {
            throw new ApiException("Invalid or missing miner address", HttpStatusCode.NotFound);
        }

        if (settings == null)
        {
            throw new ApiException("Invalid or missing settings", HttpStatusCode.BadRequest);
        }

        // map settings
        var mapped = mapper.Map <Persistence.Model.MinerSettings>(settings);

        // clamp limit
        if (pool.PaymentProcessing != null)
        {
            mapped.PaymentThreshold = Math.Max(mapped.PaymentThreshold, pool.PaymentProcessing.MinimumPayment);
        }

        mapped.PoolId  = pool.Id;
        mapped.Address = address;

        var result = await cf.RunTx(async (con, tx) =>
        {
            await minerRepo.UpdateSettingsAsync(con, tx, mapped);

            return(await minerRepo.GetSettingsAsync(con, tx, mapped.PoolId, mapped.Address));
        });

        logger.Info(() => $"Updated settings for pool {pool.Id}, miner {address}");

        return(mapper.Map <Responses.MinerSettings>(result));
    }