Skip to content

Commit

Permalink
updated schema, use bigint unsigned
Browse files Browse the repository at this point in the history
  • Loading branch information
Kriptikz committed Aug 12, 2024
1 parent bdc063f commit 279637e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion migrations/2024-08-11-151101_create_miners/up.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CREATE TABLE miners (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
pubkey VARCHAR(44) NOT NULL,
enabled BOOL DEFAULT false,
enabled BOOL DEFAULT false NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL
)
4 changes: 2 additions & 2 deletions migrations/2024-08-11-235837_create_pools/up.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CREATE TABLE pools (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
proof_pubkey VARCHAR(44) NOT NULL,
total_rewards BIGINT DEFAULT 0,
claimed_rewards BIGINT DEFAULT 0,
total_rewards BIGINT UNSIGNED DEFAULT 0,
claimed_rewards BIGINT UNSIGNED DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL
)
2 changes: 1 addition & 1 deletion migrations/2024-08-12-000144_create_challenges/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CREATE TABLE challenges (
pool_id INT NOT NULL,
submission_id INT,
challenge BINARY(32) NOT NULL,
rewards_earned BIGINT DEFAULT 0,
rewards_earned BIGINT UNSIGNED DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL
)
2 changes: 1 addition & 1 deletion migrations/2024-08-12-002816_create_submissions/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CREATE TABLE submissions (
miner_id INT NOT NULL,
challenge_id INT NOT NULL,
difficulty TINYINT NOT NULL,
nonce BIGINT NOT NULL,
nonce BIGINT UNSIGNED NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL
)
2 changes: 1 addition & 1 deletion migrations/2024-08-12-004131_create_claims/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CREATE TABLE claims (
miner_id INT NOT NULL,
pool_id INT NOT NULL,
txn_id INT NOT NULL,
amount TINYINT NOT NULL,
amount BIGINT UNSIGNED NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL
)
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ use tower_http::trace::{DefaultMakeSpan, TraceLayer};
use tracing::{error, info};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

mod models;
mod schema;


const MIN_DIFF: u32 = 8;
const MIN_HASHPOWER: u64 = 5;
Expand Down
12 changes: 6 additions & 6 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ diesel::table! {
submission_id -> Nullable<Integer>,
#[max_length = 32]
challenge -> Binary,
rewards_earned -> Nullable<Bigint>,
rewards_earned -> Nullable<Unsigned<Bigint>>,
created_at -> Timestamp,
updated_at -> Timestamp,
}
Expand All @@ -25,7 +25,7 @@ diesel::table! {
miner_id -> Integer,
pool_id -> Integer,
txn_id -> Integer,
amount -> Tinyint,
amount -> Unsigned<Bigint>,
created_at -> Timestamp,
updated_at -> Timestamp,
}
Expand All @@ -36,7 +36,7 @@ diesel::table! {
id -> Integer,
#[max_length = 44]
pubkey -> Varchar,
enabled -> Nullable<Bool>,
enabled -> Bool,
created_at -> Timestamp,
updated_at -> Timestamp,
}
Expand All @@ -47,8 +47,8 @@ diesel::table! {
id -> Integer,
#[max_length = 44]
proof_pubkey -> Varchar,
total_rewards -> Nullable<Bigint>,
claimed_rewards -> Nullable<Bigint>,
total_rewards -> Nullable<Unsigned<Bigint>>,
claimed_rewards -> Nullable<Unsigned<Bigint>>,
created_at -> Timestamp,
updated_at -> Timestamp,
}
Expand All @@ -60,7 +60,7 @@ diesel::table! {
miner_id -> Integer,
challenge_id -> Integer,
difficulty -> Tinyint,
nonce -> Bigint,
nonce -> Unsigned<Bigint>,
created_at -> Timestamp,
updated_at -> Timestamp,
}
Expand Down

0 comments on commit 279637e

Please sign in to comment.