-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schema updates, added basic models.rs
- Loading branch information
Showing
4 changed files
with
74 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
CREATE TABLE txns ( | ||
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
txn_type ENUM('mine', 'claim') NOT NULL, | ||
txn_type VARCHAR(15) NOT NULL, | ||
signature VARCHAR(200) NOT NULL, | ||
priority_fee INT UNSIGNED DEFAULT 0, | ||
priority_fee INT UNSIGNED DEFAULT 0 NOT NULL, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use diesel::prelude::*; | ||
use serde::{Serialize, Deserialize}; | ||
use chrono::NaiveDateTime; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] | ||
#[diesel(table_name = crate::schema::challenges)] | ||
#[diesel(check_for_backend(diesel::mysql::Mysql))] | ||
pub struct Challenge { | ||
pub id: i32, | ||
pub pool_id: i32, | ||
pub submission_id: Option<i32>, | ||
pub challenge: Vec<u8>, | ||
pub rewards_earned: Option<u64>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] | ||
#[diesel(table_name = crate::schema::claims)] | ||
#[diesel(check_for_backend(diesel::mysql::Mysql))] | ||
pub struct Claim { | ||
pub id: i32, | ||
pub miner_id: i32, | ||
pub pool_id: i32, | ||
pub txn_id: i32, | ||
pub amount: u64, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] | ||
#[diesel(table_name = crate::schema::miners)] | ||
#[diesel(check_for_backend(diesel::mysql::Mysql))] | ||
pub struct Miner { | ||
pub id: i32, | ||
pub pubkey: String, | ||
pub enabled: bool, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] | ||
#[diesel(table_name = crate::schema::pools)] | ||
#[diesel(check_for_backend(diesel::mysql::Mysql))] | ||
pub struct Pool { | ||
pub id: i32, | ||
pub proof_pubkey: String, | ||
pub authority_pubkey: String, | ||
pub total_rewards: Option<u64>, | ||
pub claimed_rewards: Option<u64>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] | ||
#[diesel(table_name = crate::schema::submissions)] | ||
#[diesel(check_for_backend(diesel::mysql::Mysql))] | ||
pub struct Submission { | ||
pub id: i32, | ||
pub miner_id: i32, | ||
pub challenge_id: i32, | ||
pub difficulty: i8, | ||
pub created_at: NaiveDateTime, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Queryable, Selectable, QueryableByName)] | ||
#[diesel(table_name = crate::schema::txns)] | ||
#[diesel(check_for_backend(diesel::mysql::Mysql))] | ||
pub struct Txn { | ||
pub id: i32, | ||
pub txn_type: String, | ||
pub signature: String, | ||
pub priority_fee: u32, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters