mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-04 06:13:10 +00:00
remove utxo tree
This commit is contained in:
parent
f50ef5be9a
commit
c6a4a00fda
@ -198,7 +198,6 @@ mod tests {
|
|||||||
let result = account.mark_spent_utxo(utxo_nullifier_map);
|
let result = account.mark_spent_utxo(utxo_nullifier_map);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
assert!(account.utxos.get(&account.address).is_none());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -210,7 +209,7 @@ mod tests {
|
|||||||
let result = account.add_new_utxo_outputs(vec![utxo1.clone(), utxo2.clone()]);
|
let result = account.add_new_utxo_outputs(vec![utxo1.clone(), utxo2.clone()]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
assert_eq!(account.utxos.store.len(), 2);
|
assert_eq!(account.utxos.len(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -230,6 +229,6 @@ mod tests {
|
|||||||
let result = account.add_asset(asset, amount, false);
|
let result = account.add_asset(asset, amount, false);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
assert_eq!(account.utxos.store.len(), 1);
|
assert_eq!(account.utxos.len(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,7 +125,7 @@ impl NodeChainStore {
|
|||||||
serde_json::from_slice::<UTXO>(&decoded_data_curr_acc);
|
serde_json::from_slice::<UTXO>(&decoded_data_curr_acc);
|
||||||
if let Ok(utxo) = decoded_utxo_try {
|
if let Ok(utxo) = decoded_utxo_try {
|
||||||
if &utxo.owner == acc_id {
|
if &utxo.owner == acc_id {
|
||||||
acc.utxos.insert_item(utxo)?;
|
acc.utxos.insert(utxo.hash, utxo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1062,7 +1062,7 @@ impl NodeCore {
|
|||||||
|
|
||||||
let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap();
|
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();
|
new_utxo.log();
|
||||||
@ -1103,8 +1103,7 @@ impl NodeCore {
|
|||||||
|
|
||||||
let new_utxo = acc
|
let new_utxo = acc
|
||||||
.utxos
|
.utxos
|
||||||
.get_item(new_utxo_hash)
|
.get(&new_utxo_hash)
|
||||||
.unwrap()
|
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
@ -1238,7 +1237,7 @@ impl NodeCore {
|
|||||||
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
|
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
|
||||||
acc.log();
|
acc.log();
|
||||||
|
|
||||||
acc.utxos.get_item(new_utxo_hash)?.unwrap().clone()
|
acc.utxos.get(&new_utxo_hash).unwrap().clone()
|
||||||
};
|
};
|
||||||
new_utxo.log();
|
new_utxo.log();
|
||||||
info!(
|
info!(
|
||||||
@ -1278,7 +1277,7 @@ impl NodeCore {
|
|||||||
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
|
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
|
||||||
acc.log();
|
acc.log();
|
||||||
|
|
||||||
acc.utxos.get_item(new_utxo_hash)?.unwrap().clone()
|
acc.utxos.get(&new_utxo_hash).unwrap().clone()
|
||||||
};
|
};
|
||||||
new_utxo.log();
|
new_utxo.log();
|
||||||
info!(
|
info!(
|
||||||
@ -1323,7 +1322,7 @@ impl NodeCore {
|
|||||||
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
|
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
|
||||||
acc.log();
|
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();
|
new_utxo.log();
|
||||||
info!(
|
info!(
|
||||||
@ -1343,7 +1342,7 @@ impl NodeCore {
|
|||||||
let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap();
|
let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap();
|
||||||
acc.log();
|
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();
|
new_utxo.log();
|
||||||
info!(
|
info!(
|
||||||
@ -1558,8 +1557,7 @@ impl NodeCore {
|
|||||||
|
|
||||||
let new_utxo = acc
|
let new_utxo = acc
|
||||||
.utxos
|
.utxos
|
||||||
.get_item(new_utxo_hash)
|
.get(&new_utxo_hash)
|
||||||
.unwrap()
|
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.clone();
|
.clone();
|
||||||
new_utxo.log();
|
new_utxo.log();
|
||||||
|
|||||||
@ -269,10 +269,7 @@ impl JsonHandler {
|
|||||||
|
|
||||||
let utxo = acc
|
let utxo = acc
|
||||||
.utxos
|
.utxos
|
||||||
.get_item(utxo_hash)
|
.get(&utxo_hash)
|
||||||
.map_err(|err| {
|
|
||||||
RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}"))
|
|
||||||
})?
|
|
||||||
.ok_or(RpcError::new_internal_error(
|
.ok_or(RpcError::new_internal_error(
|
||||||
None,
|
None,
|
||||||
"UTXO does not exist in the tree",
|
"UTXO does not exist in the tree",
|
||||||
@ -513,10 +510,7 @@ impl JsonHandler {
|
|||||||
.ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?;
|
.ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?;
|
||||||
|
|
||||||
acc.utxos
|
acc.utxos
|
||||||
.get_item(utxo_hash)
|
.get(&utxo_hash)
|
||||||
.map_err(|err| {
|
|
||||||
RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}"))
|
|
||||||
})?
|
|
||||||
.ok_or(RpcError::new_internal_error(
|
.ok_or(RpcError::new_internal_error(
|
||||||
None,
|
None,
|
||||||
"UTXO does not exist in tree",
|
"UTXO does not exist in tree",
|
||||||
@ -648,10 +642,7 @@ impl JsonHandler {
|
|||||||
.ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?;
|
.ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?;
|
||||||
|
|
||||||
acc.utxos
|
acc.utxos
|
||||||
.get_item(utxo_hash)
|
.get(&utxo_hash)
|
||||||
.map_err(|err| {
|
|
||||||
RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}"))
|
|
||||||
})?
|
|
||||||
.ok_or(RpcError::new_internal_error(
|
.ok_or(RpcError::new_internal_error(
|
||||||
None,
|
None,
|
||||||
"UTXO does not exist in tree",
|
"UTXO does not exist in tree",
|
||||||
@ -736,10 +727,7 @@ impl JsonHandler {
|
|||||||
.ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?;
|
.ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?;
|
||||||
|
|
||||||
acc.utxos
|
acc.utxos
|
||||||
.get_item(utxo_hash)
|
.get(&utxo_hash)
|
||||||
.map_err(|err| {
|
|
||||||
RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}"))
|
|
||||||
})?
|
|
||||||
.ok_or(RpcError::new_internal_error(
|
.ok_or(RpcError::new_internal_error(
|
||||||
None,
|
None,
|
||||||
"UTXO does not exist in tree",
|
"UTXO does not exist in tree",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user