Skip to content

Commit

Permalink
Add Miner Effort
Browse files Browse the repository at this point in the history
Co-Authored-By: Reggerriee <[email protected]>
  • Loading branch information
xiaolin1579 and Reggerriee committed Oct 11, 2023
1 parent 030ce71 commit 93fb493
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Miningcore/Api/Responses/GetBlocksResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Block
public string Type { get; set; }
public double ConfirmationProgress { get; set; }
public double? Effort { get; set; }
public double? MinerEffort { get; set; }
public string TransactionConfirmationData { get; set; }
public decimal Reward { get; set; }
public string InfoLink { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/Miningcore/Api/Responses/GetMinerStatsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class MinerStats
public decimal PendingBalance { get; set; }
public decimal TotalPaid { get; set; }
public decimal TodayPaid { get; set; }
public double MinerEffort { get; set; }
public DateTime? LastPayment { get; set; }
public string LastPaymentLink { get; set; }
public WorkerPerformanceStatsContainer Performance { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/Miningcore/Persistence/Model/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Block
public string Type { get; set; }
public double ConfirmationProgress { get; set; }
public double? Effort { get; set; }
public double? MinerEffort { get; set; }
public string TransactionConfirmationData { get; set; }
public string Miner { get; set; }
public decimal Reward { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/Miningcore/Persistence/Model/Projections/MinerStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class MinerStats
public decimal PendingBalance { get; init; }
public decimal TotalPaid { get; init; }
public decimal TodayPaid { get; init; }
public double MinerEffort { get; set; }
public Payment LastPayment { get; set; }
public WorkerPerformanceStatsContainer Performance { get; set; }
public MinerWorkerPerformanceStats[] PerformanceStats { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public async Task InsertAsync(IDbConnection con, IDbTransaction tx, Block block)

const string query =
@"INSERT INTO blocks(poolid, blockheight, networkdifficulty, status, type, transactionconfirmationdata,
miner, reward, effort, confirmationprogress, source, hash, created)
miner, reward, effort, minereffort, confirmationprogress, source, hash, created)
VALUES(@poolid, @blockheight, @networkdifficulty, @status, @type, @transactionconfirmationdata,
@miner, @reward, @effort, @confirmationprogress, @source, @hash, @created)";
@miner, @reward, (SELECT SUM(difficulty / networkdifficulty) FROM shares WHERE poolid = @poolId AND created > (SELECT created FROM blocks WHERE poolid = @poolId ORDER BY created DESC LIMIT 1) AND created < now()), (SELECT SUM(difficulty / networkdifficulty) FROM shares WHERE poolid = @poolId AND miner = @miner AND created > (SELECT created FROM blocks WHERE poolid = @poolId AND miner = @miner ORDER BY created DESC LIMIT 1) AND created < now()), @confirmationprogress, @source, @hash, @created)";

await con.ExecuteAsync(query, mapped, tx);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
\c miningcore
ALTER TABLE blocks ADD COLUMN minereffort FLOAT NULL;
1 change: 1 addition & 0 deletions src/Miningcore/Persistence/Postgres/Scripts/createdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CREATE TABLE blocks
type TEXT NULL,
confirmationprogress FLOAT NOT NULL DEFAULT 0,
effort FLOAT NULL,
minereffort FLOAT NULL,
transactionconfirmationdata TEXT NOT NULL,
miner TEXT NULL,
reward decimal(28,12) NULL,
Expand Down

0 comments on commit 93fb493

Please sign in to comment.