Skip to content

Commit 28cc681

Browse files
committed
Add an index for get_block_pre_committers
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 3e4a0ef commit 28cc681

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

libsigner/src/v0/messages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub enum SignerMessage {
187187
MockBlock(MockBlock),
188188
/// A state machine update
189189
StateMachineUpdate(StateMachineUpdate),
190-
/// The pre commit message from signers for other signers to observe
190+
/// The pre-commit message from signers for other signers to observe
191191
BlockPreCommit(Sha512Trunc256Sum),
192192
}
193193

stacks-node/src/nakamoto_node/stackerdb_listener.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl StackerDBListener {
501501
self.update_global_state_evaluator(&signer_pubkey, update);
502502
}
503503
SignerMessageV0::BlockPreCommit(_) => {
504-
debug!("Received block pre commit message. Ignoring.");
504+
debug!("Received block pre-commit message. Ignoring.");
505505
}
506506
};
507507
}

stacks-signer/src/signerdb.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,11 @@ CREATE TABLE IF NOT EXISTS block_pre_commits (
685685
PRIMARY KEY (signer_signature_hash, signer_addr)
686686
) STRICT;"#;
687687

688+
/// Used by get_block_pre_committers
689+
static CREATE_BLOCK_PRE_COMMITS_BY_SIGHASH_INDEX: &str = r#"
690+
CREATE INDEX idx_block_pre_commits_by_sighash ON block_pre_commits(signer_signature_hash);
691+
"#;
692+
688693
static SCHEMA_1: &[&str] = &[
689694
DROP_SCHEMA_0,
690695
CREATE_DB_CONFIG,
@@ -800,6 +805,7 @@ static SCHEMA_16: &[&str] = &[
800805

801806
static SCHEMA_17: &[&str] = &[
802807
CREATE_BLOCK_PRE_COMMITS_TABLE,
808+
CREATE_BLOCK_PRE_COMMITS_BY_SIGHASH_INDEX,
803809
"INSERT INTO db_config (version) VALUES (17);",
804810
];
805811

@@ -1843,7 +1849,7 @@ impl SignerDb {
18431849
Ok(None)
18441850
}
18451851

1846-
/// Record an observed block pre commit
1852+
/// Record an observed block pre-commit
18471853
pub fn add_block_pre_commit(
18481854
&self,
18491855
block_sighash: &Sha512Trunc256Sum,
@@ -1852,7 +1858,7 @@ impl SignerDb {
18521858
let qry = "INSERT OR REPLACE INTO block_pre_commits (signer_signature_hash, signer_addr) VALUES (?1, ?2);";
18531859
let args = params![block_sighash, address.to_string()];
18541860

1855-
debug!("Inserting block pre commit.";
1861+
debug!("Inserting block pre-commit.";
18561862
"signer_signature_hash" => %block_sighash,
18571863
"signer_addr" => %address);
18581864

@@ -1883,7 +1889,7 @@ impl SignerDb {
18831889
Ok(exists.is_some())
18841890
}
18851891

1886-
/// Get all pre committers for a block
1892+
/// Get all pre-committers for a block
18871893
pub fn get_block_pre_committers(
18881894
&self,
18891895
block_sighash: &Sha512Trunc256Sum,

0 commit comments

Comments
 (0)