From efe470d64d5d3b5732e09853880788f581df5781 Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Mon, 18 Dec 2023 13:15:27 -0700 Subject: [PATCH] re-add original prove for comparison --- src/storage_proofs.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/storage_proofs.rs b/src/storage_proofs.rs index 55243de..d4a2634 100644 --- a/src/storage_proofs.rs +++ b/src/storage_proofs.rs @@ -146,7 +146,7 @@ impl StorageProofs { } } -fn decode_u256(val: &rmpv::Value) -> Result { +fn decode_number(val: &rmpv::Value) -> Result { match val { rmpv::Value::Ext(id, val) => { match *id { @@ -158,7 +158,16 @@ fn decode_u256(val: &rmpv::Value) -> Result { num => return Err(format!("unhandled ext id {}", num)), } }, - _ => return Err("expected ext mpack kind".to_string()), + rmpv::Value::Integer(val) => { + if let Some(val) = val.as_u64() { + return Ok(U256::from(val)); + } else if let Some(val) = val.as_i64() { + return Ok(U256::from(val)); + } else { + return Err("unexpected integer kind".to_string()); + } + } + _ => return Err("expected ext mpack kind or integer".to_string()), } } @@ -185,7 +194,7 @@ fn parse_mpack_arrays( } else { println!("deserde: name: {}", name); for val in array { - let n = decode_u256(val)?; + let n = decode_number(val)?; println!("\t{}", n); builder.push_input(name, n); }