Skip to content

Commit bdd60ee

Browse files
small improvements
1 parent 4952631 commit bdd60ee

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
lines changed

dash/src/hash_types.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,28 +223,36 @@ impl PartialOrd for ScoreHash {
223223
}
224224

225225
impl ProTxHash {
226-
/// Create a Txid from a string
226+
/// Create a ProTxHash from a string
227227
pub fn from_hex(s: &str) -> Result<ProTxHash, Error> {
228228
Ok(Self(sha256d::Hash::from_str(s)?))
229229
}
230230

231-
/// Convert a Txid to a string
231+
/// Convert a ProTxHash to a string
232232
pub fn to_hex(&self) -> String {
233233
self.0.to_string()
234234
}
235235
}
236236

237237
impl ScoreHash {
238-
/// Create a Txid from a string
238+
/// Create a ScoreHash from a string
239239
pub fn from_hex(s: &str) -> Result<ScoreHash, Error> {
240240
Ok(Self(sha256::Hash::from_str(s)?))
241241
}
242242

243-
/// Convert a Txid to a string
243+
/// Convert a ScoreHash to a string
244244
pub fn to_hex(&self) -> String {
245245
self.0.to_string()
246246
}
247247

248+
/// Creates a score based on the optional confirmed hash and the quorum modifier.
249+
///
250+
/// # Arguments
251+
/// * `confirmed_hash_hashed_with_pro_reg_tx` - An optional hash combining the confirmed hash and ProRegTx.
252+
/// * `modifier` - A quorum modifier hash used in the calculation.
253+
///
254+
/// # Returns
255+
/// * A hashed score derived from the input values.
248256
pub fn create_score(confirmed_hash_hashed_with_pro_reg_tx: Option<ConfirmedHashHashedWithProRegTx>, modifier: QuorumModifierHash) -> Self {
249257
let mut bytes = vec![];
250258
if let Some(confirmed_hash_hashed_with_pro_reg_tx) = confirmed_hash_hashed_with_pro_reg_tx{

dash/src/network/message_qrinfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl Decodable for QRInfo {
154154
pub struct QuorumSnapshot {
155155
pub skip_list_mode: MNSkipListMode,
156156
pub active_quorum_members: Vec<bool>, // Bitset, length = (active_quorum_members_count + 7) / 8
157-
pub skip_list: Vec<u32>, // Array of int32_t
157+
pub skip_list: Vec<u32>, // Array of uint32_t
158158
}
159159

160160
impl Display for QuorumSnapshot {

dash/src/sml/llmq_entry_verification.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ impl Display for LLMQEntryVerificationSkipStatus {
2323
match self {
2424
LLMQEntryVerificationSkipStatus::NotMarkedForVerification =>
2525
"NotMarkedForVerification".to_string(),
26-
LLMQEntryVerificationSkipStatus::MissedList(block_height) =>
27-
format!("MissedList({})", block_height),
28-
LLMQEntryVerificationSkipStatus::UnknownBlock(block_hash) =>
29-
format!("UnknownBlock({})", hex::encode(block_hash)),
30-
LLMQEntryVerificationSkipStatus::OtherContext(message) =>
31-
format!("OtherContext({message})"),
26+
LLMQEntryVerificationSkipStatus::MissedList(block_height) => {
27+
format!("MissedList({})", block_height)
28+
}
29+
LLMQEntryVerificationSkipStatus::UnknownBlock(block_hash) => {
30+
format!("UnknownBlock({})", hex::encode(block_hash))
31+
}
32+
LLMQEntryVerificationSkipStatus::OtherContext(message) => {
33+
format!("OtherContext({message})")
34+
}
3235
}
3336
.as_str(),
3437
)

dash/src/sml/llmq_type/mod.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,6 @@ pub const LLMQ_0024: LLMQParams = LLMQParams {
151151
keep_old_connections: 4,
152152
recovery_members: 4,
153153
};
154-
pub const LLMQ_0024_333: LLMQParams = LLMQParams {
155-
quorum_type: LLMQType::LlmqtypeDevnetDIP0024,
156-
name: "llmq_devnet_dip0024",
157-
size: 8,
158-
min_size: 6,
159-
threshold: 4,
160-
dkg_params: DKG_DEVNET_DIP_0024,
161-
signing_active_quorum_count: 2,
162-
keep_old_connections: 4,
163-
recovery_members: 4,
164-
};
165154
pub const LLMQ_TEST_DIP00024: LLMQParams = LLMQParams {
166155
quorum_type: LLMQType::LlmqtypeTestDIP0024,
167156
name: "llmq_test_dip0024",

dash/src/sml/masternode_list_engine/rotated_quorum_construction.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,11 @@ impl MasternodeListEngine {
382382
snapshot
383383
.skip_list
384384
.iter()
385-
.filter_map(|unskipped| {
386-
sorted_combined_mns_list.get(*unskipped as usize)
385+
.filter_map(|not_skipped| {
386+
sorted_combined_mns_list.get(*not_skipped as usize)
387387
})
388388
.take(quarter_size)
389-
.cloned()
389+
.copied()
390390
.collect()
391391
})
392392
.collect(),
@@ -400,9 +400,9 @@ impl MasternodeListEngine {
400400
LLMQQuarterUsageType::New(mut used_indexed_masternodes) => {
401401
let mut quarter_quorum_members =
402402
vec![Vec::<&QualifiedMasternodeListEntry>::new(); quorum_count];
403-
let mut skip_list = Vec::<i32>::new();
404-
let mut first_skipped_index = 0i32;
405-
let mut idx = 0i32;
403+
let mut skip_list = Vec::<u32>::new();
404+
let mut first_skipped_index = 0u32;
405+
let mut idx = 0u32;
406406
for i in 0..quorum_count {
407407
let masternodes_used_at_h_indexed_at_i = used_indexed_masternodes
408408
.get_mut(i)
@@ -430,7 +430,7 @@ impl MasternodeListEngine {
430430
updated = true;
431431
}
432432
idx += 1;
433-
if idx == sorted_combined_mns_list_len as i32 {
433+
if idx == sorted_combined_mns_list_len as u32 {
434434
idx = 0;
435435
}
436436
if idx == initial_loop_idx {

dash/src/sml/quorum_entry/validation.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ impl QualifiedQuorumEntry {
5858
.collect::<Vec<_>>();
5959
let sig =
6060
G2Element::from_bytes(self.quorum_entry.all_commitment_aggregated_signature.as_bytes())
61-
.expect("expected sig");
61+
.map_err(|e| {
62+
QuorumValidationError::AllCommitmentAggregatedSignatureNotValid(e.to_string())
63+
})?;
6264
let verified = BasicSchemeMPL::new().verify_secure(public_keys2.iter(), message, &sig);
6365
if verified {
6466
Ok(())

0 commit comments

Comments
 (0)