Skip to content

Commit

Permalink
Remove LDK funds migration code (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-21 authored Oct 1, 2024
1 parent 4e836c5 commit d7c96d5
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 358 deletions.
65 changes: 2 additions & 63 deletions src/data_store.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use crate::analytics::AnalyticsConfig;
use crate::errors::Result;
use crate::fund_migration::MigrationStatus;
use crate::migrations::migrate;
use crate::{EnableStatus, ExchangeRate, OfferKind, PocketOfferError, TzConfig, UserPreferences};
use pocketclient::FiatTopupInfo;

use crate::analytics::AnalyticsConfig;
use chrono::{DateTime, Utc};
use crow::{PermanentFailureCode, TemporaryFailureCode};
use perro::MapToError;
use pocketclient::FiatTopupInfo;
use rusqlite::{backup, params, Connection, OptionalExtension, Params, Row};
use std::time::{Duration, SystemTime, UNIX_EPOCH};

Expand Down Expand Up @@ -300,37 +299,6 @@ impl DataStore {
.collect()
}

pub fn append_funds_migration_status(&mut self, status: MigrationStatus) -> Result<()> {
self.backup_status = BackupStatus::WaitingForBackup;
self.conn
.execute(
"INSERT INTO funds_migration_status (status) VALUES (?1)",
(status as u8,),
)
.map_to_permanent_failure("Failed to add funds migration ststus to db")?;
Ok(())
}

pub fn retrieve_funds_migration_status(&self) -> Result<MigrationStatus> {
let status_from_row = |row: &Row| {
let status: u8 = row.get(0)?;
MigrationStatus::try_from(status).map_err(|e| {
rusqlite::Error::FromSqlConversionFailure(
1,
rusqlite::types::Type::Integer,
Box::new(e),
)
})
};
self.conn
.query_row(
"SELECT status, updated_at FROM funds_migration_status ORDER BY id DESC LIMIT 1",
(),
status_from_row,
)
.map_to_permanent_failure("Failed to query funds migration status")
}

pub fn store_fiat_topup_info(&self, fiat_topup_info: FiatTopupInfo) -> Result<()> {
let dt: DateTime<Utc> = SystemTime::now().into();
self.conn
Expand Down Expand Up @@ -690,7 +658,6 @@ fn fiat_topup_info_from_row(row: &Row) -> rusqlite::Result<Option<FiatTopupInfo>
mod tests {
use crate::config::TzConfig;
use crate::data_store::{CreatedInvoice, DataStore};
use crate::fund_migration::MigrationStatus;
use crate::{EnableStatus, ExchangeRate, OfferKind, PocketOfferError, UserPreferences};

use crate::analytics::AnalyticsConfig;
Expand Down Expand Up @@ -1142,34 +1109,6 @@ mod tests {
);
}

#[test]
fn test_persisting_funds_migration_status() {
let db_name = String::from("funds_migration.db3");
reset_db(&db_name);
let mut data_store = DataStore::new(&format!("{TEST_DB_PATH}/{db_name}")).unwrap();

assert_eq!(
data_store.retrieve_funds_migration_status().unwrap(),
MigrationStatus::Unknown
);

data_store
.append_funds_migration_status(MigrationStatus::Pending)
.unwrap();
assert_eq!(
data_store.retrieve_funds_migration_status().unwrap(),
MigrationStatus::Pending
);

data_store
.append_funds_migration_status(MigrationStatus::Completed)
.unwrap();
assert_eq!(
data_store.retrieve_funds_migration_status().unwrap(),
MigrationStatus::Completed
);
}

#[test]
fn test_invoice_persistence() {
let db_name = String::from("invoice_persistence.db3");
Expand Down
3 changes: 0 additions & 3 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ pub enum RuntimeErrorCode {
// Breez runtime errors
/// Information about the remote node isn't cached and couldn't be accessed. Could be a network error.
NodeUnavailable,
// Temporary migration error
/// Migration of funds from legacy LDK wallet failed. Retry is recommended.
FailedFundMigration,
}

impl Display for RuntimeErrorCode {
Expand Down
272 changes: 0 additions & 272 deletions src/fund_migration.rs

This file was deleted.

Loading

0 comments on commit d7c96d5

Please sign in to comment.