Skip to content
Snippets Groups Projects
Commit 4ce40a98 authored by Éloïs's avatar Éloïs
Browse files

feat(dbs):bc_v2: add fields created_on & signature for IdtyDbV2

parent 116bdbe4
No related branches found
No related tags found
No related merge requests found
Pipeline #12407 passed
......@@ -177,6 +177,7 @@ mod tests {
version: 10,
median_time: 5_243,
dividend: Some(1000),
identities: vec!["D9D2zaJoWYWveii1JRYLVK3J4Z7ZH3QczoKrnQeiM6mx:Ydnclvw76/JHcKSmU9kl9Ie0ne5/X8NYOqPqbGnufIK3eEPRYYdEYaQh+zffuFhbtIRjv6m/DkVLH5cLy/IyAg==:0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855:elois".to_owned()],
joiners: vec!["D9D2zaJoWYWveii1JRYLVK3J4Z7ZH3QczoKrnQeiM6mx:FFeyrvYio9uYwY5aMcDGswZPNjGLrl8THn9l3EPKSNySD3SDSHjCljSfFEwb87sroyzJQoVzPwER0sW/cbZMDg==:0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855:0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855:elois".to_owned()],
inner_hash: Some("0000000A65A12DB95B3153BCD05DB4D5C30CC7F0B1292D9FFBC3DE67F72F6040".to_owned()),
signature: "7B0hvcfajE2G8nBLp0vLVaQcQdQIyli21Gu8F2l+nimKHRe+fUNi+MWd1e/u29BYZa+RZ1yxhbHIbFzytg7fAA==".to_owned(),
......
......@@ -27,21 +27,19 @@ pub(crate) fn update_identities<B: Backend>(
identities.upsert(
PubKeyKeyV2(pubkey),
IdtyDbV2 {
created_on: idty.blockstamp(),
is_member: true,
username,
signature: idty.signatures()[0],
},
)
}
for mb in block.joiners() {
let pubkey = mb.issuers()[0];
let username = mb.identity_username().to_owned();
identities.upsert(
PubKeyKeyV2(pubkey),
IdtyDbV2 {
is_member: true,
username,
},
)
if let Some(mut idty) = identities.get(&PubKeyKeyV2(pubkey))? {
idty.is_member = true;
identities.upsert(PubKeyKeyV2(pubkey), idty)
}
}
for revo in block.revoked() {
let pubkey = revo.issuer;
......@@ -65,14 +63,10 @@ pub(crate) fn revert_identities<B: Backend>(
) -> KvResult<()> {
for mb in block.joiners() {
let pubkey = mb.issuers()[0];
let username = mb.identity_username().to_owned();
identities.upsert(
PubKeyKeyV2(pubkey),
IdtyDbV2 {
is_member: false,
username,
},
)
if let Some(mut idty) = identities.get(&PubKeyKeyV2(pubkey))? {
idty.is_member = false;
identities.upsert(PubKeyKeyV2(pubkey), idty)
}
}
for idty in block.identities() {
let pubkey = idty.issuers()[0];
......
......@@ -39,7 +39,7 @@ pub struct BlockMetaV2 {
pub nonce: u64, // 8
pub monetary_mass: u64, // 8
pub unit_base: u32, // 4
pub dividend: Option<SourceAmount>, // 17 -> TOTAL SIZE == 335 bytes
pub dividend: Option<SourceAmount>, // 17 -> TOTAL SIZE == 323 bytes
}
impl BlockMetaV2 {
pub fn blockstamp(&self) -> Blockstamp {
......
......@@ -17,8 +17,10 @@ use crate::*;
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IdtyDbV2 {
pub created_on: Blockstamp,
pub is_member: bool,
pub username: String,
pub signature: Signature,
}
impl AsBytes for IdtyDbV2 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment