Skip to content

Commit c032a1a

Browse files
committed
Improve policy conversion
1 parent a2161d2 commit c032a1a

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

crates/services/block_aggregator_api/src/blocks/importer_and_db_source/serializer_adapter.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -609,25 +609,23 @@ fn proto_policies_from_policies(
609609
policies: &fuel_core_types::fuel_tx::policies::Policies,
610610
) -> ProtoPolicies {
611611
let mut values = [0u64; 6];
612-
if policies.is_set(PolicyType::Tip) {
613-
values[0] = policies.get(PolicyType::Tip).unwrap_or_default();
612+
if let Some(value) = policies.get(PolicyType::Tip) {
613+
values[0] = value;
614614
}
615-
if policies.is_set(PolicyType::WitnessLimit) {
616-
let value = policies.get(PolicyType::WitnessLimit).unwrap_or_default();
615+
if let Some(value) = policies.get(PolicyType::WitnessLimit) {
617616
values[1] = value;
618617
}
619-
if policies.is_set(PolicyType::Maturity) {
620-
let value = policies.get(PolicyType::Maturity).unwrap_or_default();
618+
if let Some(value) = policies.get(PolicyType::Maturity) {
621619
values[2] = value;
622620
}
623-
if policies.is_set(PolicyType::MaxFee) {
624-
values[3] = policies.get(PolicyType::MaxFee).unwrap_or_default();
621+
if let Some(value) = policies.get(PolicyType::MaxFee) {
622+
values[3] = value;
625623
}
626-
if policies.is_set(PolicyType::Expiration) {
627-
values[4] = policies.get(PolicyType::Expiration).unwrap_or_default();
624+
if let Some(value) = policies.get(PolicyType::Expiration) {
625+
values[4] = value;
628626
}
629-
if policies.is_set(PolicyType::Owner) {
630-
values[5] = policies.get(PolicyType::Owner).unwrap_or_default();
627+
if let Some(value) = policies.get(PolicyType::Owner) {
628+
values[5] = value;
631629
}
632630
let bits = policies.bits();
633631
ProtoPolicies {

0 commit comments

Comments
 (0)