Skip to content

Commit

Permalink
inline NB_ARUMENTS
Browse files Browse the repository at this point in the history
  • Loading branch information
grooviegermanikus committed Nov 13, 2023
1 parent 7036783 commit 76396c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions history/src/postgres/postgres_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ pub struct PostgresBlock {
pub rewards: Option<String>,
}

const NB_ARUMENTS: usize = 7;

impl From<&ProducedBlock> for PostgresBlock {
fn from(value: &ProducedBlock) -> Self {
let rewards = value
Expand Down Expand Up @@ -67,9 +65,11 @@ impl PostgresBlock {
postgres_session: &PostgresSession,
epoch: EpochRef,
) -> anyhow::Result<()> {
const NB_ARGUMENTS: usize = 7;

let started = Instant::now();
let schema = PostgresEpoch::build_schema_name(epoch);
let values = PostgresSession::values_vecvec(NB_ARUMENTS, 1, &[]);
let values = PostgresSession::values_vecvec(NB_ARGUMENTS, 1, &[]);

let statement = format!(
r#"
Expand All @@ -88,7 +88,7 @@ impl PostgresBlock {
schema = schema,
);

let mut args: Vec<&(dyn ToSql + Sync)> = Vec::with_capacity(NB_ARUMENTS);
let mut args: Vec<&(dyn ToSql + Sync)> = Vec::with_capacity(NB_ARGUMENTS);
args.push(&self.slot);
args.push(&self.blockhash);
args.push(&self.block_height);
Expand Down
7 changes: 3 additions & 4 deletions history/src/postgres/postgres_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ pub struct PostgresTransaction {
pub message: String,
}

const NB_ARUMENTS: usize = 8;

impl PostgresTransaction {
pub fn new(value: &TransactionInfo, slot: Slot) -> Self {
Self {
Expand Down Expand Up @@ -79,8 +77,9 @@ impl PostgresTransaction {
slot: Slot,
transactions: &[Self],
) -> anyhow::Result<()> {
const NB_ARGUMENTS: usize = 8;
let tx_count = transactions.len();
let mut args: Vec<&(dyn ToSql + Sync)> = Vec::with_capacity(NB_ARUMENTS * tx_count);
let mut args: Vec<&(dyn ToSql + Sync)> = Vec::with_capacity(NB_ARGUMENTS * tx_count);

for tx in transactions.iter() {
let PostgresTransaction {
Expand All @@ -104,7 +103,7 @@ impl PostgresTransaction {
args.push(message);
}

let values = PostgresSession::values_vecvec(NB_ARUMENTS, tx_count, &[]);
let values = PostgresSession::values_vecvec(NB_ARGUMENTS, tx_count, &[]);
let schema = PostgresEpoch::build_schema_name(epoch);
let statement = format!(
r#"
Expand Down

0 comments on commit 76396c3

Please sign in to comment.