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

[feat] gva: block: add field monetaryMass

parent 64c11438
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,8 @@ pub trait BlockDocumentTrait {
fn issuers_count(&self) -> UsizeSer32;
/// Get number of members in wot
fn members_count(&self) -> UsizeSer32;
/// Get amount of monetary mass
fn monetary_mass(&self) -> u64;
/// Get block number
fn number(&self) -> BlockNumber;
/// Get common difficulty (PoW)
......@@ -170,6 +172,12 @@ impl BlockDocumentTrait for BlockDocument {
}
}
#[inline]
fn monetary_mass(&self) -> u64 {
match self {
BlockDocument::V10(block) => block.monetary_mass(),
}
}
#[inline]
fn common_time(&self) -> u64 {
match self {
BlockDocument::V10(block) => block.common_time(),
......
......@@ -278,6 +278,9 @@ Transactions:{transactions}
fn members_count(&self) -> UsizeSer32 {
self.members_count
}
fn monetary_mass(&self) -> u64 {
self.monetary_mass
}
fn number(&self) -> BlockNumber {
self.number
}
......
......@@ -84,6 +84,7 @@ type Block {
issuerName: String,
issuersCount: Int!
membersCount: Int!
monetaryMass: Int!,
number: Int!
hash: String!,
blockchainTime: DateTimeUtc!
......
......@@ -33,6 +33,7 @@ pub struct Block {
issuer_name: Option<String>,
issuers_count: i32,
members_count: i32,
monetary_mass: i32,
number: i32,
hash: String,
blockchain_time: NaiveDateTime,
......@@ -61,6 +62,7 @@ impl Block {
},
issuers_count: block_db.block.issuers_count().into(),
members_count: block_db.block.members_count().into(),
monetary_mass: block_db.block.monetary_mass() as i32,
number: block_db.block.number().0 as i32,
hash: block_db
.block
......@@ -120,4 +122,8 @@ impl super::super::BlockFields for Block {
fn field_members_count(&self, _executor: &Executor<'_, QueryContext>) -> FieldResult<&i32> {
Ok(&self.members_count)
}
#[inline]
fn field_monetary_mass(&self, _executor: &Executor<'_, QueryContext>) -> FieldResult<&i32> {
Ok(&self.monetary_mass)
}
}
......@@ -71,6 +71,7 @@ mod tests {
);
block.issuers = vec![pubkey('B')];
block.issuers_count = UsizeSer32(3);
block.monetary_mass = 5900;
block.pow_min = UsizeSer32(70);
Ok(Some(BlockDb {
block: BlockDocument::V10(block),
......@@ -101,7 +102,7 @@ mod tests {
tests::test_gql_query(
schema,
"{ block(number: 42) { blockchainTime, currency, hash, issuer, issuerName, issuersCount, number, powMin, version } }",
"{ block(number: 42) { blockchainTime, currency, hash, issuer, issuerName, issuersCount, monetaryMass, number, powMin, version } }",
json!({
"data": {
"block": {
......@@ -111,6 +112,7 @@ mod tests {
"issuer": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
"issuerName": "issuerName",
"issuersCount": 3,
"monetaryMass": 5900,
"number": 42,
"powMin": 70,
"version": 10
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment