Skip to content
Snippets Groups Projects
Commit e81ec3f9 authored by jm's avatar jm
Browse files

[feat] gva: add unitBase field

parent 4c0c2d40
Branches
No related tags found
No related merge requests found
......@@ -93,6 +93,8 @@ pub trait BlockDocumentTrait {
fn verify_hash(&self) -> Result<(), VerifyBlockHashError>;
/// Sign block
fn sign(&mut self, signator: &SignatorEnum);
/// Get unit_base
fn unit_base(&self) -> usize;
}
impl BlockDocumentTrait for BlockDocument {
......@@ -222,6 +224,12 @@ impl BlockDocumentTrait for BlockDocument {
BlockDocument::V10(block) => block.sign(signator),
}
}
#[inline]
fn unit_base(&self) -> usize {
match self {
BlockDocument::V10(block) => block.unit_base(),
}
}
}
impl Document for BlockDocument {
......
......@@ -362,6 +362,9 @@ Transactions:{transactions}
}),
}
}
fn unit_base(&self) -> usize {
self.unit_base
}
}
impl Document for BlockDocumentV10 {
......
......@@ -88,6 +88,7 @@ type Block {
hash: String!,
commonTime: DateTimeUtc!
powMin: Int!
unitBase: Int!
}
#################################
......
......@@ -37,6 +37,7 @@ pub struct Block {
hash: String,
common_time: NaiveDateTime,
pow_min: i32,
unit_base: i32,
}
impl Block {
......@@ -69,6 +70,7 @@ impl Block {
.to_string(),
common_time: NaiveDateTime::from_timestamp(block_db.block.common_time() as i64, 0),
pow_min: block_db.block.pow_min() as i32,
unit_base: block_db.block.unit_base() as i32,
})
}
}
......@@ -117,6 +119,10 @@ impl super::super::BlockFields for Block {
Ok(&self.issuers_count)
}
#[inline]
fn field_unit_base(&self, _executor: &Executor<'_, QueryContext>) -> FieldResult<&i32> {
Ok(&self.unit_base)
}
#[inline]
fn field_members_count(&self, _executor: &Executor<'_, QueryContext>) -> FieldResult<&i32> {
Ok(&self.members_count)
}
......
......@@ -59,6 +59,7 @@ mod tests {
current_block.issuers = vec![pubkey('B')];
current_block.pow_min = 70;
current_block.members_count = 59;
current_block.unit_base = 1;
Ok(Some(BlockDb {
block: BlockDocument::V10(current_block),
expire_certs: None,
......@@ -74,7 +75,7 @@ mod tests {
tests::test_gql_query(
schema,
"{ current { commonTime, currency, hash, issuer, issuerName, membersCount, number, powMin, version } }",
"{ current { commonTime, currency, hash, issuer, issuerName, membersCount, number, powMin, version, unitBase } }",
json!({
"data": {
"current": {
......@@ -86,7 +87,8 @@ mod tests {
"membersCount": 59,
"number": 42,
"powMin": 70,
"version": 10
"version": 10,
"unitBase": 1,
}
}
}),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment