Skip to content

Commit

Permalink
feat(data_request): modify sorting in get_all_reveals
Browse files Browse the repository at this point in the history
  • Loading branch information
lrubiorod committed Sep 6, 2021
1 parent 65861a2 commit 86ffe89
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions data_structures/src/data_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{
radon_report::{RadonReport, Stage, TypeLike},
transaction::{CommitTransaction, DRTransaction, RevealTransaction, TallyTransaction},
};
use witnet_crypto::hash::calculate_sha256;

/// Pool of active data requests
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -83,8 +84,14 @@ impl DataRequestPool {
dr_state.info.reveals.values().cloned().collect();
reveals.sort_unstable_by_key(|reveal| {
if active_wips.wip0019() {
// TODO: Hash(pkh+dr)
PublicKeyHash::default()
let mut bytes_to_hash = vec![];
bytes_to_hash.extend(reveal.body.pkh.hash);
bytes_to_hash.extend(dr_pointer.as_ref());

let hashed_bytes = calculate_sha256(bytes_to_hash.as_ref()).0;

// We are forcing 20 bytes, so we can not obtain an error here
PublicKeyHash::from_bytes(&hashed_bytes[..20]).unwrap()
} else {
reveal.body.pkh
}
Expand Down

0 comments on commit 86ffe89

Please sign in to comment.