remove utxo tree

This commit is contained in:
Sergio Chouhy 2025-05-16 20:25:23 -03:00
parent f50ef5be9a
commit c6a4a00fda
4 changed files with 14 additions and 29 deletions

View File

@ -198,7 +198,6 @@ mod tests {
let result = account.mark_spent_utxo(utxo_nullifier_map);
assert!(result.is_ok());
assert!(account.utxos.get(&account.address).is_none());
}
#[test]
@ -210,7 +209,7 @@ mod tests {
let result = account.add_new_utxo_outputs(vec![utxo1.clone(), utxo2.clone()]);
assert!(result.is_ok());
assert_eq!(account.utxos.store.len(), 2);
assert_eq!(account.utxos.len(), 2);
}
#[test]
@ -230,6 +229,6 @@ mod tests {
let result = account.add_asset(asset, amount, false);
assert!(result.is_ok());
assert_eq!(account.utxos.store.len(), 1);
assert_eq!(account.utxos.len(), 1);
}
}

View File

@ -125,7 +125,7 @@ impl NodeChainStore {
serde_json::from_slice::<UTXO>(&decoded_data_curr_acc);
if let Ok(utxo) = decoded_utxo_try {
if &utxo.owner == acc_id {
acc.utxos.insert_item(utxo)?;
acc.utxos.insert(utxo.hash, utxo);
}
}
}

View File

@ -1062,7 +1062,7 @@ impl NodeCore {
let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap();
acc.utxos.get_item(new_utxo_hash)?.unwrap().clone()
acc.utxos.get(&new_utxo_hash).unwrap().clone()
};
new_utxo.log();
@ -1103,8 +1103,7 @@ impl NodeCore {
let new_utxo = acc
.utxos
.get_item(new_utxo_hash)
.unwrap()
.get(&new_utxo_hash)
.unwrap()
.clone();
@ -1238,7 +1237,7 @@ impl NodeCore {
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
acc.log();
acc.utxos.get_item(new_utxo_hash)?.unwrap().clone()
acc.utxos.get(&new_utxo_hash).unwrap().clone()
};
new_utxo.log();
info!(
@ -1278,7 +1277,7 @@ impl NodeCore {
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
acc.log();
acc.utxos.get_item(new_utxo_hash)?.unwrap().clone()
acc.utxos.get(&new_utxo_hash).unwrap().clone()
};
new_utxo.log();
info!(
@ -1323,7 +1322,7 @@ impl NodeCore {
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
acc.log();
let new_utxo = acc.utxos.get_item(new_utxo_hash)?.unwrap().clone();
let new_utxo = acc.utxos.get(&new_utxo_hash).unwrap().clone();
new_utxo.log();
info!(
@ -1343,7 +1342,7 @@ impl NodeCore {
let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap();
acc.log();
let new_utxo = acc.utxos.get_item(new_utxo_hash)?.unwrap().clone();
let new_utxo = acc.utxos.get(&new_utxo_hash).unwrap().clone();
new_utxo.log();
info!(
@ -1558,8 +1557,7 @@ impl NodeCore {
let new_utxo = acc
.utxos
.get_item(new_utxo_hash)
.unwrap()
.get(&new_utxo_hash)
.unwrap()
.clone();
new_utxo.log();

View File

@ -269,10 +269,7 @@ impl JsonHandler {
let utxo = acc
.utxos
.get_item(utxo_hash)
.map_err(|err| {
RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}"))
})?
.get(&utxo_hash)
.ok_or(RpcError::new_internal_error(
None,
"UTXO does not exist in the tree",
@ -513,10 +510,7 @@ impl JsonHandler {
.ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?;
acc.utxos
.get_item(utxo_hash)
.map_err(|err| {
RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}"))
})?
.get(&utxo_hash)
.ok_or(RpcError::new_internal_error(
None,
"UTXO does not exist in tree",
@ -648,10 +642,7 @@ impl JsonHandler {
.ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?;
acc.utxos
.get_item(utxo_hash)
.map_err(|err| {
RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}"))
})?
.get(&utxo_hash)
.ok_or(RpcError::new_internal_error(
None,
"UTXO does not exist in tree",
@ -736,10 +727,7 @@ impl JsonHandler {
.ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?;
acc.utxos
.get_item(utxo_hash)
.map_err(|err| {
RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}"))
})?
.get(&utxo_hash)
.ok_or(RpcError::new_internal_error(
None,
"UTXO does not exist in tree",