-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/1412-yesNoChoiceComponent
- Loading branch information
Showing
24 changed files
with
738 additions
and
679 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
3 changes: 3 additions & 0 deletions
3
catalyst-gateway/bin/src/db/index/queries/cql/get_all_stake_addrs.cql
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 @@ | ||
SELECT | ||
stake_address,vote_key | ||
FROM cip36_registration; |
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
catalyst-gateway/bin/src/db/index/queries/registrations/get_all_stakes_and_vote_keys.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 @@ | ||
//! Get all stake and vote keys (`stake_pub_key,vote_key`) | ||
//! Result is used to compose various query registrations for snapshot. | ||
use std::sync::Arc; | ||
|
||
use scylla::{ | ||
prepared_statement::PreparedStatement, transport::iterator::TypedRowStream, DeserializeRow, | ||
SerializeRow, Session, | ||
}; | ||
use tracing::error; | ||
|
||
use crate::db::index::{ | ||
queries::{PreparedQueries, PreparedSelectQuery}, | ||
session::CassandraSession, | ||
}; | ||
|
||
/// Get all (`stake_addr,vote` keys) | ||
/// [(`stake_addr,vote_key`)] | ||
const GET_ALL_STAKES_AND_VOTE_KEYS: &str = include_str!("../cql/get_all_stake_addrs.cql"); | ||
|
||
/// Get all stake and vote keys from cip36 registration | ||
#[derive(SerializeRow)] | ||
pub(crate) struct GetAllStakesAndVoteKeysParams {} | ||
|
||
/// Get stakes and vote keys for snapshot. | ||
#[derive(DeserializeRow)] | ||
pub(crate) struct GetAllStakesAndVoteKeysQuery { | ||
/// Full Stake Address (not hashed, 32 byte ED25519 Public key). | ||
pub stake_address: Vec<u8>, | ||
/// Voting Public Key | ||
pub vote_key: Vec<u8>, | ||
} | ||
|
||
impl GetAllStakesAndVoteKeysQuery { | ||
/// Prepares get all `stake_addr` paired with vote keys [(`stake_addr,vote_key`)] | ||
pub(crate) async fn prepare(session: Arc<Session>) -> anyhow::Result<PreparedStatement> { | ||
let get_all_stake_and_vote_keys = PreparedQueries::prepare( | ||
session, | ||
GET_ALL_STAKES_AND_VOTE_KEYS, | ||
scylla::statement::Consistency::All, | ||
true, | ||
) | ||
.await; | ||
|
||
get_all_stake_and_vote_keys.inspect_err( | ||
|error| error!(error=%error, "Failed to prepare get all (stake addrs, vote_keys)"), | ||
) | ||
} | ||
|
||
/// Executes get all `stake_addr` paired with vote keys [(`stake_addr,vote_key`)] | ||
pub(crate) async fn execute( | ||
session: &CassandraSession, params: GetAllStakesAndVoteKeysParams, | ||
) -> anyhow::Result<TypedRowStream<GetAllStakesAndVoteKeysQuery>> { | ||
let iter = session | ||
.execute_iter(PreparedSelectQuery::GetAllStakesAndVoteKeys, params) | ||
.await? | ||
.rows_stream::<GetAllStakesAndVoteKeysQuery>()?; | ||
|
||
Ok(iter) | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
catalyst-gateway/bin/src/db/index/schema/cql/cip36_registration_for_vote_key.cql
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
72 changes: 60 additions & 12 deletions
72
catalyst-gateway/bin/src/service/api/cardano/cip36/endpoint.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
Oops, something went wrong.