lib: rename and use existing structs (Db)SpendBlock

This commit is contained in:
jp1ac4 committed 2023-04-04 09:27:03 +01:00
1 parent 4cb6d2dc69
commit b519c8d185
5 files changed
+14 -39

No files matched your search

+5 -5
View File
@@ -585,7 +585,7 @@ impl SqliteConn {
#[cfg(test)]
mod tests {
use super::*;
use crate::database::{BlockInfo, DbBlockInfo, SpendBlock};
use crate::database::{BlockInfo, DbBlockInfo};
use crate::testutils::*;
use std::{
collections::{HashMap, HashSet},
@@ -1005,7 +1005,7 @@ mod tests {
)
.unwrap(),
),
spend_block: Some(SpendBlock {
spend_block: Some(BlockInfo {
height: 101_199,
time: 1_231_678,
}),
@@ -1043,7 +1043,7 @@ mod tests {
)
.unwrap(),
),
spend_block: Some(SpendBlock {
spend_block: Some(BlockInfo {
height: 101_105,
time: 1_201_678,
}),
@@ -1218,7 +1218,7 @@ mod tests {
)
.unwrap(),
),
spend_block: Some(SpendBlock {
spend_block: Some(BlockInfo {
height: 101_199,
time: 1_123_000,
}),
@@ -1256,7 +1256,7 @@ mod tests {
)
.unwrap(),
),
spend_block: Some(SpendBlock {
spend_block: Some(BlockInfo {
height: 101_105,
time: 1_126_000,
}),
+2 -8
View File
@@ -147,12 +147,6 @@ impl TryFrom<&rusqlite::Row<'_>> for DbWallet {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DbSpendBlock {
pub height: i32,
pub time: u32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DbBlockInfo {
pub height: i32,
@@ -169,7 +163,7 @@ pub struct DbCoin {
pub derivation_index: bip32::ChildNumber,
pub is_change: bool,
pub spend_txid: Option<bitcoin::Txid>,
pub spend_block: Option<DbSpendBlock>,
pub spend_block: Option<DbBlockInfo>,
}
impl TryFrom<&rusqlite::Row<'_>> for DbCoin {
@@ -203,7 +197,7 @@ impl TryFrom<&rusqlite::Row<'_>> for DbCoin {
let spend_height: Option<i32> = row.get(10)?;
let spend_time: Option<u32> = row.get(11)?;
assert_eq!(spend_height.is_none(), spend_time.is_none());
let spend_block = spend_height.map(|height| DbSpendBlock {
let spend_block = spend_height.map(|height| DbBlockInfo {
height,
time: spend_time.expect("Must be there if height is"),
});