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

[feat] gva: add issuersFrame issuersFrameVar field

parent e81ec3f9
No related branches found
No related tags found
No related merge requests found
......@@ -95,6 +95,8 @@ pub trait BlockDocumentTrait {
fn sign(&mut self, signator: &SignatorEnum);
/// Get unit_base
fn unit_base(&self) -> usize;
/// Get issuers_frame_var
fn issuers_frame_var(&self) -> isize;
}
impl BlockDocumentTrait for BlockDocument {
......@@ -230,6 +232,12 @@ impl BlockDocumentTrait for BlockDocument {
BlockDocument::V10(block) => block.unit_base(),
}
}
#[inline]
fn issuers_frame_var(&self) -> isize {
match self {
BlockDocument::V10(block) => block.issuers_frame_var(),
}
}
}
impl Document for BlockDocument {
......
......@@ -365,6 +365,9 @@ Transactions:{transactions}
fn unit_base(&self) -> usize {
self.unit_base
}
fn issuers_frame_var(&self) -> isize {
self.issuers_frame_var
}
}
impl Document for BlockDocumentV10 {
......
......@@ -89,6 +89,8 @@ type Block {
commonTime: DateTimeUtc!
powMin: Int!
unitBase: Int!
issuersFrame: Int!
issuersFrameVar: Int!
}
#################################
......
......@@ -38,6 +38,8 @@ pub struct Block {
common_time: NaiveDateTime,
pow_min: i32,
unit_base: i32,
issuers_frame: i32,
issuers_frame_var: i32,
}
impl Block {
......@@ -71,6 +73,8 @@ impl Block {
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,
issuers_frame: block_db.block.current_frame_size() as i32,
issuers_frame_var: block_db.block.issuers_frame_var() as i32,
})
}
}
......@@ -126,4 +130,12 @@ impl super::super::BlockFields for Block {
fn field_members_count(&self, _executor: &Executor<'_, QueryContext>) -> FieldResult<&i32> {
Ok(&self.members_count)
}
#[inline]
fn field_issuers_frame(&self, _executor: &Executor<'_, QueryContext>) -> FieldResult<&i32> {
Ok(&self.issuers_frame)
}
#[inline]
fn field_issuers_frame_var(&self, _executor: &Executor<'_, QueryContext>) -> FieldResult<&i32> {
Ok(&self.issuers_frame_var)
}
}
......@@ -71,6 +71,8 @@ mod tests {
block.issuers = vec![pubkey('B')];
block.issuers_count = 3;
block.pow_min = 70;
block.issuers_frame = 125;
block.issuers_frame_var = 3;
Ok(Some(BlockDb {
block: BlockDocument::V10(block),
expire_certs: None,
......@@ -100,7 +102,7 @@ mod tests {
tests::test_gql_query(
schema,
"{ block(number: 42) { commonTime, currency, hash, issuer, issuerName, issuersCount, number, powMin, version } }",
"{ block(number: 42) { commonTime, currency, hash, issuer, issuerName, issuersCount, number, powMin, version, issuersFrame, issuersFrameVar } }",
json!({
"data": {
"block": {
......@@ -112,7 +114,9 @@ mod tests {
"issuersCount": 3,
"number": 42,
"powMin": 70,
"version": 10
"version": 10,
"issuersFrame": 125,
"issuersFrameVar": 3,
}
}
}),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment