-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbb90f8
commit 0b24a50
Showing
31 changed files
with
385 additions
and
35 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
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ pub mod balance; | |
pub mod crawler; | ||
pub mod gov; | ||
pub mod pos; | ||
pub mod revealed_pk; |
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,22 @@ | ||
use anyhow::Context; | ||
use diesel::{PgConnection, RunQueryDsl}; | ||
use orm::{revealed_pk::RevealedPkInsertDb, schema::revealed_pk}; | ||
use shared::{id::Id, public_key::PublicKey}; | ||
|
||
pub fn insert_revealed_pks( | ||
transaction_conn: &mut PgConnection, | ||
revealed_pks: Vec<(PublicKey, Id)>, | ||
) -> anyhow::Result<()> { | ||
diesel::insert_into(revealed_pk::table) | ||
.values::<&Vec<RevealedPkInsertDb>>( | ||
&revealed_pks | ||
.into_iter() | ||
.map(|(pk, address)| RevealedPkInsertDb::from(pk, address)) | ||
.collect::<Vec<_>>(), | ||
) | ||
.on_conflict_do_nothing() | ||
.execute(transaction_conn) | ||
.context("Failed to update balances in db")?; | ||
|
||
anyhow::Ok(()) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- This file should undo anything in `up.sql` | ||
|
||
DROP TABLE IF EXISTS revealed_pk; |
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,9 @@ | ||
-- Your SQL goes here | ||
|
||
CREATE TABLE revealed_pk ( | ||
id SERIAL PRIMARY KEY, | ||
address VARCHAR NOT NULL, | ||
pk VARCHAR NOT NULL | ||
); | ||
|
||
ALTER TABLE revealed_pk ADD UNIQUE (address, pk); |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use diesel::{Insertable, Queryable, Selectable}; | ||
use shared::{id::Id, public_key::PublicKey}; | ||
|
||
use crate::schema::revealed_pk; | ||
|
||
#[derive(Insertable, Clone, Queryable, Selectable)] | ||
#[diesel(table_name = revealed_pk)] | ||
#[diesel(check_for_backend(diesel::pg::Pg))] | ||
pub struct RevealedPkInsertDb { | ||
pub pk: String, | ||
pub address: String, | ||
} | ||
|
||
pub type RevealedPkDb = RevealedPkInsertDb; | ||
|
||
impl RevealedPkInsertDb { | ||
pub fn from(pk: PublicKey, address: Id) -> Self { | ||
Self { | ||
pk: pk.0, | ||
address: address.to_string(), | ||
} | ||
} | ||
} |
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
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,9 @@ | ||
use namada_sdk::key::common::PublicKey as NamadaPublicKey; | ||
|
||
pub struct PublicKey(pub String); | ||
|
||
impl From<NamadaPublicKey> for PublicKey { | ||
fn from(pk: NamadaPublicKey) -> Self { | ||
PublicKey(pk.to_string()) | ||
} | ||
} |
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
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 +1 @@ | ||
cargo run -- --database-url postgres://postgres:[email protected]:5435/namada-indexer --cache-url redis://[email protected]:6379 | ||
cargo run -- --database-url postgres://postgres:[email protected]:5435/namada-indexer --cache-url redis://[email protected]:6379 --tendermint-url http://127.0.0.1:27657 |
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
Oops, something went wrong.