Skip to content

Commit

Permalink
Merge pull request #2936 from dusk-network/neotamandua/change_sqlite_…
Browse files Browse the repository at this point in the history
…schema

Change SQLite schema & adjust archive to it
  • Loading branch information
Neotamandua authored Nov 13, 2024
2 parents 3f3f1a4 + 650fbd7 commit 72ac19e
Show file tree
Hide file tree
Showing 29 changed files with 784 additions and 360 deletions.
24 changes: 23 additions & 1 deletion node-data/src/events/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ pub struct ContractTxEvent {
#[repr(C)]
pub struct WrappedContractId(pub ContractId);

impl TryFrom<String> for WrappedContractId {
type Error = anyhow::Error;

fn try_from(value: String) -> std::result::Result<Self, Self::Error> {
let source_bytes = hex::decode(value)?;
let mut source_array = [0u8; CONTRACT_ID_BYTES];

if source_bytes.len() != CONTRACT_ID_BYTES {
return Err(anyhow::anyhow!(
"Invalid length: expected {} bytes, got {}",
CONTRACT_ID_BYTES,
source_bytes.len()
));
} else {
source_array.copy_from_slice(&source_bytes);
}

Ok(WrappedContractId(ContractId::from_bytes(source_array)))
}
}

impl Serialize for WrappedContractId {
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
where
Expand All @@ -54,9 +75,10 @@ impl<'de> Deserialize<'de> for WrappedContractId {
CONTRACT_ID_BYTES,
source_bytes.len()
)));
} else {
source_array.copy_from_slice(&source_bytes);
}

source_array.copy_from_slice(&source_bytes);
Ok(WrappedContractId(ContractId::from_bytes(source_array)))
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Loading

0 comments on commit 72ac19e

Please sign in to comment.