db: re-rename list_unspent_coins into unspent_coins
This commit is contained in:
parent
3534e35b87
commit
c9b6c6dedb
@ -28,7 +28,7 @@ fn update_coins(
|
||||
previous_tip: &BlockChainTip,
|
||||
) -> UpdatedCoins {
|
||||
// Start by fetching newly received coins.
|
||||
let curr_coins = db_conn.list_unspent_coins();
|
||||
let curr_coins = db_conn.unspent_coins();
|
||||
let mut received = Vec::new();
|
||||
for utxo in bit.received_coins(&previous_tip) {
|
||||
if let Some(derivation_index) = db_conn.derivation_index_by_address(&utxo.address) {
|
||||
|
||||
@ -197,7 +197,7 @@ impl DaemonControl {
|
||||
pub fn list_coins(&self) -> ListCoinsResult {
|
||||
let mut db_conn = self.db.connection();
|
||||
let coins: Vec<ListCoinsEntry> = db_conn
|
||||
.list_unspent_coins()
|
||||
.unspent_coins()
|
||||
// Can't use into_values as of Rust 1.48
|
||||
.into_iter()
|
||||
.map(|(_, coin)| {
|
||||
|
||||
@ -55,7 +55,7 @@ pub trait DatabaseConnection {
|
||||
) -> Option<bip32::ChildNumber>;
|
||||
|
||||
/// Get all UTxOs.
|
||||
fn list_unspent_coins(&mut self) -> HashMap<bitcoin::OutPoint, Coin>;
|
||||
fn unspent_coins(&mut self) -> HashMap<bitcoin::OutPoint, Coin>;
|
||||
|
||||
/// List coins that are being spent and whose spending transaction is still unconfirmed.
|
||||
fn list_spending_coins(&mut self) -> HashMap<bitcoin::OutPoint, Coin>;
|
||||
@ -118,8 +118,8 @@ impl DatabaseConnection for SqliteConn {
|
||||
self.increment_derivation_index(secp)
|
||||
}
|
||||
|
||||
fn list_unspent_coins(&mut self) -> HashMap<bitcoin::OutPoint, Coin> {
|
||||
self.list_unspent_coins()
|
||||
fn unspent_coins(&mut self) -> HashMap<bitcoin::OutPoint, Coin> {
|
||||
self.unspent_coins()
|
||||
.into_iter()
|
||||
.map(|db_coin| (db_coin.outpoint, db_coin.into()))
|
||||
.collect()
|
||||
|
||||
@ -253,7 +253,7 @@ impl SqliteConn {
|
||||
}
|
||||
|
||||
/// Get all UTxOs.
|
||||
pub fn list_unspent_coins(&mut self) -> Vec<DbCoin> {
|
||||
pub fn unspent_coins(&mut self) -> Vec<DbCoin> {
|
||||
db_query(
|
||||
&mut self.conn,
|
||||
"SELECT * FROM coins WHERE spend_txid is NULL",
|
||||
@ -553,7 +553,7 @@ mod tests {
|
||||
let mut conn = db.connection().unwrap();
|
||||
|
||||
// Necessarily empty at first.
|
||||
assert!(conn.list_unspent_coins().is_empty());
|
||||
assert!(conn.unspent_coins().is_empty());
|
||||
|
||||
// Add one, we'll get it.
|
||||
let coin_a = Coin {
|
||||
@ -569,7 +569,7 @@ mod tests {
|
||||
spent_at: None,
|
||||
};
|
||||
conn.new_unspent_coins(&[coin_a.clone()]); // On 1.48, arrays aren't IntoIterator
|
||||
assert_eq!(conn.list_unspent_coins()[0].outpoint, coin_a.outpoint);
|
||||
assert_eq!(conn.unspent_coins()[0].outpoint, coin_a.outpoint);
|
||||
|
||||
// We can query it by its outpoint
|
||||
let coins = conn.db_coins(&[coin_a.outpoint]);
|
||||
@ -591,7 +591,7 @@ mod tests {
|
||||
};
|
||||
conn.new_unspent_coins(&[coin_b.clone()]);
|
||||
let outpoints: HashSet<bitcoin::OutPoint> = conn
|
||||
.list_unspent_coins()
|
||||
.unspent_coins()
|
||||
.into_iter()
|
||||
.map(|c| c.outpoint)
|
||||
.collect();
|
||||
@ -620,7 +620,7 @@ mod tests {
|
||||
let height = 174500;
|
||||
let time = 174500;
|
||||
conn.confirm_coins(&[(coin_a.outpoint, height, time)]);
|
||||
let coins = conn.list_unspent_coins();
|
||||
let coins = conn.unspent_coins();
|
||||
assert_eq!(coins[0].block_height, Some(height));
|
||||
assert_eq!(coins[0].block_time, Some(time));
|
||||
assert!(coins[1].block_height.is_none());
|
||||
@ -632,7 +632,7 @@ mod tests {
|
||||
bitcoin::Txid::from_slice(&[0; 32][..]).unwrap(),
|
||||
)]);
|
||||
let outpoints: HashSet<bitcoin::OutPoint> = conn
|
||||
.list_unspent_coins()
|
||||
.unspent_coins()
|
||||
.into_iter()
|
||||
.map(|c| c.outpoint)
|
||||
.collect();
|
||||
|
||||
@ -114,7 +114,7 @@ impl DatabaseConnection for DummyDbConn {
|
||||
self.db.write().unwrap().curr_index = next_index;
|
||||
}
|
||||
|
||||
fn list_unspent_coins(&mut self) -> HashMap<bitcoin::OutPoint, Coin> {
|
||||
fn unspent_coins(&mut self) -> HashMap<bitcoin::OutPoint, Coin> {
|
||||
self.db.read().unwrap().coins.clone()
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user