Skip to content

Commit

Permalink
Merge pull request #44 from stakwork/kvv
Browse files Browse the repository at this point in the history
fix initial get
  • Loading branch information
Evanfeenstra authored Sep 12, 2023
2 parents 5de0f94 + 507f236 commit b253ca3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ serde = { version = "1.0.168", default-features = false, features = ["derive"] }
hex = { version = "0.4.3", default-features = false }
anyhow = { version = "1", default-features = false }
fsdb = { git = "https://github.com/Evanfeenstra/fsdb.git", rev = "13f66653ec3c14280fc8ab330108c710c1df3006", optional = true }
# fsdb = { path = "../../fsdb", optional = true }
thiserror = "1.0.44"
# vls
vls-protocol-signer = { git = "https://gitlab.com/lightning-signer/validating-lightning-signer.git", rev = "4b2a00975a5c7ccdbcedf6dcf44728b90b296064", default-features = false, features = ["secp-lowmemory"] }
Expand Down
17 changes: 9 additions & 8 deletions signer/src/kvv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl FsKVVStore {
let mut versions = BTreeMap::new();
let fulllist = bucket.list_all().expect("could not list bucket");
for path in fulllist {
match bucket.get(&path) {
match bucket.get_raw(&path) {
Ok(item) => {
let (version, _) = Self::decode_vv(&item);
versions.insert(path, version);
Expand Down Expand Up @@ -167,15 +167,16 @@ impl KVVStore for FsKVVStore {
.list(prefix)
.map_err(|_| Error::Internal("could not list".to_string()))?;
let mut result = Vec::new();
for mut item in items {
if item.starts_with("/") {
item.remove(0);
}
let key = format!("{}/{}", prefix, item);
log::info!("LIST RES {:?}", key);
for item in items {
let sep = if prefix.ends_with("/") {
"".to_string()
} else {
"/".to_string()
};
let key = format!("{}{}{}", prefix, sep, item);
let vv = self
.db
.get(&key)
.get_raw(&key)
.map_err(|_| Error::Internal("could not get".to_string()))?;
let (version, value) = Self::decode_vv(&vv);
result.push(KVV(key, (version, value)));
Expand Down
3 changes: 2 additions & 1 deletion vls-mqtt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ rumqttc = { version = "0.21.0", features = ["url"] }
dotenv = "0.15.0"
fern = "0.6"
chrono = "0.4"
fsdb = { version = "0.1.11" }
fsdb = { version = "0.1.15" }
# fsdb = { path = "../../fsdb" }
anyhow = "1"
rand = "0.8.5"

Expand Down
12 changes: 6 additions & 6 deletions vls-mqtt/src/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ impl ControlPersist for ControlPersister {
Ok(u64::from_be_bytes(r))
}
fn set_nonce(&mut self, nonce: u64) -> Result<()> {
Ok(self.nonce.put("nonce", nonce.to_be_bytes())?)
Ok(self.nonce.put("nonce", &nonce.to_be_bytes())?)
}
fn read_config(&self) -> Result<Config> {
Ok(self.config.get("config")?)
}
fn write_config(&mut self, conf: Config) -> Result<()> {
Ok(self.config.put("config", conf)?)
Ok(self.config.put("config", &conf)?)
}
fn remove_config(&mut self) -> Result<()> {
Ok(self.config.remove("config")?)
Expand All @@ -46,7 +46,7 @@ impl ControlPersist for ControlPersister {
Ok(self.seed.get("seed")?)
}
fn write_seed(&mut self, s: [u8; 32]) -> Result<()> {
Ok(self.seed.put("seed", s)?)
Ok(self.seed.put("seed", &s)?)
}
fn remove_seed(&mut self) -> Result<()> {
Ok(self.seed.remove("seed")?)
Expand All @@ -55,13 +55,13 @@ impl ControlPersist for ControlPersister {
Ok(self.id.get("id")?)
}
fn write_id(&mut self, id: String) -> Result<()> {
Ok(self.id.put("id", id)?)
Ok(self.id.put("id", &id)?)
}
fn read_policy(&self) -> Result<Policy> {
Ok(self.policy.get("policy")?)
}
fn write_policy(&mut self, pol: Policy) -> Result<()> {
Ok(self.policy.put("policy", pol)?)
Ok(self.policy.put("policy", &pol)?)
}
fn remove_policy(&mut self) -> Result<()> {
Ok(self.policy.remove("policy")?)
Expand All @@ -70,6 +70,6 @@ impl ControlPersist for ControlPersister {
Ok(self.velocity.get("velocity")?)
}
fn write_velocity(&mut self, v: Velocity) -> Result<()> {
Ok(self.velocity.put("velocity", v)?)
Ok(self.velocity.put("velocity", &v)?)
}
}

0 comments on commit b253ca3

Please sign in to comment.