diff --git a/dbs-write-ops/src/bc.rs b/dbs-write-ops/src/bc.rs index 17b2c1bc26d049bf6103a43b3d08849496a0b1c4..2c4892f3a7e3281fc5c7bd5cfef93d307a926c7d 100644 --- a/dbs-write-ops/src/bc.rs +++ b/dbs-write-ops/src/bc.rs @@ -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(), diff --git a/dbs-write-ops/src/bc/identities.rs b/dbs-write-ops/src/bc/identities.rs index 0249308747014d1ce3f7ea5ffe6f5631ac97b00b..4eea2fbba1c0aca96ef82298912cde7f87faea56 100644 --- a/dbs-write-ops/src/bc/identities.rs +++ b/dbs-write-ops/src/bc/identities.rs @@ -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]; diff --git a/dbs/src/values/block_meta.rs b/dbs/src/values/block_meta.rs index 92eaee0934ac0f66b4f6988976043d4ac9a97ff3..9c42e267fea8c4371096b0b6caaecfa27870199d 100644 --- a/dbs/src/values/block_meta.rs +++ b/dbs/src/values/block_meta.rs @@ -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 { diff --git a/dbs/src/values/idty_db.rs b/dbs/src/values/idty_db.rs index 688e1f9b6e53874badedf129889960bc702189a4..2a633846b1ae10885e9349eee6259393066ee2f7 100644 --- a/dbs/src/values/idty_db.rs +++ b/dbs/src/values/idty_db.rs @@ -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 {