-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Tree Transaction Backfiller (#114)
* refactor(backfiller): tree backfilling using getSignaturesForAdress. fetch all trees, fetch associated transactions * feat(backfiller): generate table and model for query last transaction record for fast forwarding tree transaction crawling * feat(backfiller): push transaction payloads to redis through the perkle messenger. mark tree transactons as processed_at so know it completed the index loop. * fix(backfiller): git history changes made from running formatter. just include changes needed by the backfiller. * fix(backfiller): support mock feature for sea-orm by switching to pg pool and sea_orm adapter.
- Loading branch information
1 parent
f3986ae
commit 2a12b85
Showing
20 changed files
with
887 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Empty file.
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 |
---|---|---|
|
@@ -16,3 +16,4 @@ pub mod sea_orm_active_enums; | |
pub mod tasks; | ||
pub mod token_accounts; | ||
pub mod tokens; | ||
pub mod tree_transactions; |
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
67 changes: 67 additions & 0 deletions
67
digital_asset_types/src/dao/generated/tree_transactions.rs
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,67 @@ | ||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.5 | ||
|
||
use sea_orm::entity::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Copy, Clone, Default, Debug, DeriveEntity)] | ||
pub struct Entity; | ||
|
||
impl EntityName for Entity { | ||
fn table_name(&self) -> &str { | ||
"tree_transactions" | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] | ||
pub struct Model { | ||
pub signature: String, | ||
pub tree: Vec<u8>, | ||
pub slot: i64, | ||
pub created_at: Option<DateTimeWithTimeZone>, | ||
pub processed_at: Option<DateTimeWithTimeZone>, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] | ||
pub enum Column { | ||
Signature, | ||
Tree, | ||
Slot, | ||
CreatedAt, | ||
ProcessedAt, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] | ||
pub enum PrimaryKey { | ||
Signature, | ||
} | ||
|
||
impl PrimaryKeyTrait for PrimaryKey { | ||
type ValueType = String; | ||
fn auto_increment() -> bool { | ||
false | ||
} | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter)] | ||
pub enum Relation {} | ||
|
||
impl ColumnTrait for Column { | ||
type EntityName = Entity; | ||
fn def(&self) -> ColumnDef { | ||
match self { | ||
Self::Signature => ColumnType::Char(Some(84u32)).def(), | ||
Self::Tree => ColumnType::Binary.def(), | ||
Self::Slot => ColumnType::BigInteger.def(), | ||
Self::CreatedAt => ColumnType::TimestampWithTimeZone.def().null(), | ||
Self::ProcessedAt => ColumnType::TimestampWithTimeZone.def().null(), | ||
} | ||
} | ||
} | ||
|
||
impl RelationTrait for Relation { | ||
fn def(&self) -> RelationDef { | ||
panic!("No RelationDef") | ||
} | ||
} | ||
|
||
impl ActiveModelBehavior for ActiveModel {} |
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
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
61 changes: 61 additions & 0 deletions
61
migration/src/m20231208_103949_create_tree_transactions_table.rs
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,61 @@ | ||
use sea_orm_migration::prelude::*; | ||
|
||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.create_table( | ||
Table::create() | ||
.table(TreeTransactions::Table) | ||
.if_not_exists() | ||
.col( | ||
ColumnDef::new(TreeTransactions::Signature) | ||
.char_len(88) | ||
.not_null() | ||
.primary_key(), | ||
) | ||
.col(ColumnDef::new(TreeTransactions::Tree).binary().not_null()) | ||
.col(ColumnDef::new(TreeTransactions::Slot).big_integer().not_null()) | ||
.col(ColumnDef::new(TreeTransactions::CreatedAt).timestamp_with_time_zone().default("now()")) | ||
.col(ColumnDef::new(TreeTransactions::ProcessedAt).timestamp_with_time_zone()) | ||
.to_owned(), | ||
) | ||
.await?; | ||
|
||
manager | ||
.create_index( | ||
Index::create() | ||
.name("tree_slot_index") | ||
.table(TreeTransactions::Table) | ||
.col(TreeTransactions::Tree) | ||
.col(TreeTransactions::Slot) | ||
.unique() | ||
.to_owned(), | ||
) | ||
.await | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.drop_index(Index::drop().name("tree_slot_index").table(TreeTransactions::Table).to_owned()) | ||
.await?; | ||
|
||
manager | ||
.drop_table(Table::drop().table(TreeTransactions::Table).to_owned()) | ||
.await | ||
} | ||
} | ||
|
||
/// Learn more at https://docs.rs/sea-query#iden | ||
#[derive(Iden)] | ||
enum TreeTransactions { | ||
Table, | ||
Signature, | ||
Tree, | ||
CreatedAt, | ||
ProcessedAt, | ||
Slot, | ||
} |
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
Oops, something went wrong.