Skip to content

Commit

Permalink
Align examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed May 14, 2021
1 parent 2f5de60 commit f42432f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 33 deletions.
19 changes: 7 additions & 12 deletions examples/create_max_dust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,17 @@ async fn main() -> Result<()> {
// We use the outputs directly so we don't double spend them
let mut initial_outputs = Vec::new();
if let Some(Payload::Transaction(tx)) = message.payload() {
match tx.essence() {
Essence::Regular(essence) => {
for (index, output) in essence.outputs().iter().enumerate() {
// Only include 1 Mi outputs, otherwise it fails for the remainder address
if let Output::SignatureLockedSingle(output) = output {
if output.amount() == 1_000_001 {
initial_outputs.push(UtxoInput::new(tx.id(), index as u16)?);
}
}
let Essence::Regular(essence) = tx.essence();
for (index, output) in essence.outputs().iter().enumerate() {
// Only include 1 Mi outputs, otherwise it fails for the remainder address
if let Output::SignatureLockedSingle(output) = output {
if output.amount() == 1_000_001 {
initial_outputs.push(UtxoInput::new(tx.id(), index as u16)?);
}
}
_ => {
panic!("Non-existing essence type");
}
}
}

let first_address_old_seed = iota.get_addresses(&seed).with_range(0..1).finish().await?;
let mut sent_messages = Vec::new();
for (index, output) in initial_outputs.into_iter().enumerate() {
Expand Down
19 changes: 7 additions & 12 deletions examples/split_outputs_single_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,17 @@ async fn main() -> Result<()> {
// We use the outputs directly so we don't double spend them
let mut initial_outputs = Vec::new();
if let Some(Payload::Transaction(tx)) = message.payload() {
match tx.essence() {
Essence::Regular(essence) => {
for (index, output) in essence.outputs().iter().enumerate() {
// Only include 1 Mi outputs, otherwise it fails for the remainder address
if let Output::SignatureLockedSingle(output) = output {
if output.amount() == 1_000_000 {
initial_outputs.push(UtxoInput::new(tx.id(), index as u16).unwrap());
}
}
let Essence::Regular(essence) = tx.essence();
for (index, output) in essence.outputs().iter().enumerate() {
// Only include 1 Mi outputs, otherwise it fails for the remainder address
if let Output::SignatureLockedSingle(output) = output {
if output.amount() == 1_000_000 {
initial_outputs.push(UtxoInput::new(tx.id(), index as u16).unwrap());
}
}
_ => {
panic!("Non-existing essence type");
}
}
}

let mut sent_messages = Vec::new();
for (index, output) in initial_outputs.into_iter().enumerate() {
let message_id = iota
Expand Down
12 changes: 3 additions & 9 deletions examples/txspam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,9 @@ async fn main() -> Result<()> {
// Use own outputs directly so we don't double spend them
let mut initial_outputs = Vec::new();
if let Some(Payload::Transaction(tx)) = message.payload() {
match tx.essence() {
Essence::Regular(essence) => {
for (index, _output) in essence.outputs().iter().enumerate() {
initial_outputs.push(UtxoInput::new(tx.id(), index as u16)?);
}
}
_ => {
panic!("Non-existing essence type");
}
let Essence::Regular(essence) = tx.essence();
for (index, _output) in essence.outputs().iter().enumerate() {
initial_outputs.push(UtxoInput::new(tx.id(), index as u16)?);
}
}

Expand Down

0 comments on commit f42432f

Please sign in to comment.