Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hex encode the data field of the online transaction #2993

Open
wants to merge 1 commit into
base: albatross
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pow-migration/src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn generate_ready_tx(validator: String, hash: &Blake2bHash) -> OutgoingTrans
/// - Sender: Validator address
/// - Recipient: Burn address
/// - Value: 1 Luna
/// - Data: "online"
/// - Data: "online" as hex representation
pub fn generate_online_tx(validator: String) -> OutgoingTransaction {
log::debug!(
validator_address = validator,
Expand All @@ -72,7 +72,7 @@ pub fn generate_online_tx(validator: String) -> OutgoingTransaction {
to: Address::burn_address().to_user_friendly_address(),
value: 1, //Lunas
fee: 0,
data: Some("online".to_string()),
data: Some(hex::encode(String::from("online"))),
}
}

Expand Down Expand Up @@ -132,7 +132,7 @@ fn is_valid_ready_txn(
/// Checks if the provided transaction meets the criteria in order to be
/// considered a valid online-transaction
fn is_valid_online_txn(txn: &TransactionDetails, block_window: &Range<u32>) -> bool {
Some("online".to_string()) == txn.data
Some(hex::encode(String::from("online"))) == txn.data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um guessing this is optimized by the compiler for being static?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, but it also doesn't really matter.

Suggested change
Some(hex::encode(String::from("online"))) == txn.data
Some(hex::encode("online")) == txn.data
Suggested change
Some(hex::encode(String::from("online"))) == txn.data
txn.data.as_ref().is_some_and(|hex| hex == "6f6e6c696e65") // "online"

&& block_window.contains(&txn.block_number)
&& txn.to_address == Address::burn_address().to_user_friendly_address()
}
Expand Down
Loading