Skip to content

Commit

Permalink
chore: fmt with new nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 8, 2023
1 parent 23706b5 commit bd10d34
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn_call_width = 100
format_code_in_doc_comments = true
fn_single_line = true
format_macro_matchers = true
format_macro_bodues = true
format_macro_bodies = true
format_strings = true
merge_derives = false
overflow_delimited_expr = true
Expand Down
6 changes: 3 additions & 3 deletions src/contract/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ impl ContractHistory {
}
}

// We skip removing of invalidated state for the cases of re-orgs or unmined witness
// transactions committing to the new state.
// We skip removing of invalidated state for the cases of re-orgs or unmined
// witness transactions committing to the new state.
// TODO: Expose an API to prune historic state by witness txid
/*
// Remove invalidated state
Expand Down Expand Up @@ -519,7 +519,7 @@ impl ContractState {
.get(&state_type)
.expect("global type is not in the schema");
let Some(state) = self.global.get(&state_type) else {
return SmallVec::new()
return SmallVec::new();
};
let iter = state.values().take(schema.max_items as usize);
SmallVec::try_from_iter(iter).expect("same size as previous confined collection")
Expand Down
34 changes: 21 additions & 13 deletions src/validation/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,13 @@ impl<'consignment, 'resolver, C: ConsignmentApi, R: ResolveTx>
OpRef::Extension(ref extension) => {
for (valency, prev_id) in &extension.redeemed {
let Some(prev_op) = self.consignment.operation(*prev_id) else {
self.status.add_failure(Failure::ValencyNoParent { opid, prev_id: *prev_id, valency: *valency });
continue;
};
self.status.add_failure(Failure::ValencyNoParent {
opid,
prev_id: *prev_id,
valency: *valency,
});
continue;
};

if !prev_op.valencies().contains(valency) {
self.status.add_failure(Failure::NoPrevValency {
Expand Down Expand Up @@ -387,28 +391,32 @@ impl<'consignment, 'resolver, C: ConsignmentApi, R: ResolveTx>
let Opout { op, ty, no } = input.prev_out;

let Some(prev_op) = self.consignment.operation(op) else {
// Node, referenced as the ancestor, was not found in the consignment.
// Node, referenced as the ancestor, was not found in the consignment.
// Usually this means that the consignment data are broken
self.status
.add_failure(Failure::OperationAbsent(op));
continue
self.status.add_failure(Failure::OperationAbsent(op));
continue;
};

let Some(variant) = prev_op.assignments_by_type(ty) else {
self.status.add_failure(Failure::NoPrevState { opid, prev_id: op, state_type: ty });
continue
self.status.add_failure(Failure::NoPrevState {
opid,
prev_id: op,
state_type: ty,
});
continue;
};

let Ok(seal) = variant.revealed_seal_at(no) else {
self.status.add_failure(Failure::NoPrevOut(opid,input.prev_out));
continue
self.status
.add_failure(Failure::NoPrevOut(opid, input.prev_out));
continue;
};
let Some(seal) = seal else {
// Everything is ok, but we have incomplete data (confidential), thus can't do a
// Everything is ok, but we have incomplete data (confidential), thus can't do a
// full verification and have to report the failure
self.status
.add_failure(Failure::ConfidentialSeal(input.prev_out));
continue
continue;
};

let seal = match (seal.txid, self.anchor_index.get(&op)) {
Expand Down
12 changes: 8 additions & 4 deletions src/vm/op_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ impl InstructionSet for ContractOp {
let Some(Ok(state)) = context
.prev_state
.get(state_type)
.map(|a| a.as_structured_state_at(*index)) else {
.map(|a| a.as_structured_state_at(*index))
else {
fail!()
};
let state = state.map(|s| {
Expand All @@ -185,7 +186,8 @@ impl InstructionSet for ContractOp {
let Some(Ok(state)) = context
.owned_state
.get(*state_type)
.map(|a| a.into_structured_state_at(*index)) else {
.map(|a| a.into_structured_state_at(*index))
else {
fail!()
};
let state = state.map(|s| {
Expand All @@ -198,7 +200,8 @@ impl InstructionSet for ContractOp {
let Some(Ok(state)) = context
.owned_state
.get(*state_type)
.map(|a| a.into_fungible_state_at(*index)) else {
.map(|a| a.into_fungible_state_at(*index))
else {
fail!()
};
regs.set(RegA::A64, *reg, state.map(|s| s.value.as_u64()));
Expand All @@ -207,7 +210,8 @@ impl InstructionSet for ContractOp {
let Some(state) = context
.global
.get(state_type)
.and_then(|a| a.get(*index as usize)) else {
.and_then(|a| a.get(*index as usize))
else {
fail!()
};
regs.set_s(*reg, Some(state.as_inner()));
Expand Down

0 comments on commit bd10d34

Please sign in to comment.