Fix later

This commit is contained in:
decentclock
2022-07-20 18:42:01 -06:00
parent 4834106595
commit 8172ea6232
2 changed files with 33 additions and 9 deletions

View File

@@ -12,3 +12,4 @@ serde = { version = "1.0.105" }
hex = "0.4.3"
fsdb = "0.1.10"
log = "0.4"
esp-idf-sys = { version = "0.31.6", features = ["binstart"] }

View File

@@ -10,11 +10,17 @@ use lightning_signer_server::persist::model::{
AllowlistItemEntry, ChainTrackerEntry, ChannelEntry, NodeEntry,
};
use std::string::String;
use std::str::from_utf8;
use std::mem::transmute;
use lightning_signer::persist::model::{
ChannelEntry as CoreChannelEntry, NodeEntry as CoreNodeEntry,
};
use esp_idf_sys::{closedir, opendir, readdir};
use esp_idf_sys::c_types::c_char;
const FAT32_MAXFILENAMESIZE: usize = 8;
pub struct FsPersister {
@@ -170,17 +176,34 @@ impl Persist for FsPersister {
entry.allowlist
}
fn get_nodes(&self) -> Vec<(PublicKey, CoreNodeEntry)> {
log::warn!("=> Get nodes called");
let mut res = Vec::new();
let list = match self.nodes.list() {
Ok(ns) => ns,
Err(_) => return res,
};
for pk in list {
if let Ok(pubkey) = self.pubkeys.get(&pk) {
if let Ok(node) = self.nodes.get(&pk) {
res.push((pubkey, node.into()));
}
const C_NODE_DIR: &'static [u8] = b"/sdcard/store/nodes\0";
unsafe {
let dir = opendir(
C_NODE_DIR.as_ptr() as *const c_char,
);
log::warn!("=> Nodes directory opened");
if std::ptr::null() == dir {
panic!("No nodes directory found");
}
log::warn!("=> Nodes directory is not null, start to read...");
let mut dir_ent = readdir(dir);
log::warn!("=> I am here");
while std::ptr::null() != dir_ent {
log::warn!("=> Good morning");
log::warn!("{:?}", from_utf8(transmute((*dir_ent).d_name.as_slice())));
log::warn!("Good afternoon");
/*
if let Ok(pubkey) = self.pubkeys.get(&pk) {
if let Ok(node) = self.nodes.get(&pk) {
res.push((pubkey, node.into()));
}
}
*/
dir_ent = readdir(dir);
}
closedir(dir);
}
res
}