Skip to content

Commit e8c4a9b

Browse files
authored
Merge pull request #142 from input-output-hk/golddydev/refactor-epoch-activity
refactor: add rollback support to epoch activity counter
2 parents bf390fd + 2cc0688 commit e8c4a9b

File tree

19 files changed

+596
-535
lines changed

19 files changed

+596
-535
lines changed

Cargo.lock

Lines changed: 33 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/src/queries/epochs.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{messages::EpochActivityMessage, KeyHash};
1+
use crate::{messages::EpochActivityMessage, protocol_params::ProtocolParams, KeyHash};
22

33
pub const DEFAULT_EPOCHS_QUERY_TOPIC: (&str, &str) =
44
("epochs-state-query-topic", "cardano.query.epochs");
@@ -16,6 +16,7 @@ pub enum EpochsStateQuery {
1616

1717
// Pools related queries
1818
GetBlocksMintedByPools { vrf_key_hashes: Vec<KeyHash> },
19+
GetTotalBlocksMintedByPools { vrf_key_hashes: Vec<KeyHash> },
1920
}
2021

2122
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
@@ -31,6 +32,7 @@ pub enum EpochsStateQueryResponse {
3132

3233
// Pools related responses
3334
BlocksMintedByPools(BlocksMintedByPools),
35+
TotalBlocksMintedByPools(TotalBlocksMintedByPools),
3436

3537
NotFound,
3638
Error(String),
@@ -42,7 +44,14 @@ pub struct LatestEpoch {
4244
}
4345

4446
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
45-
pub struct EpochInfo {}
47+
pub struct LatestEpochParameters {
48+
pub parameters: ProtocolParams,
49+
}
50+
51+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
52+
pub struct EpochInfo {
53+
pub epoch: EpochActivityMessage,
54+
}
4655

4756
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
4857
pub struct NextEpochs {}
@@ -67,3 +76,9 @@ pub struct BlocksMintedByPools {
6776
// this is in same order of vrf_key_hashes from EpochsStateQuery::BlocksMintedByPools
6877
pub blocks_minted: Vec<u64>,
6978
}
79+
80+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
81+
pub struct TotalBlocksMintedByPools {
82+
// this is in same order of vrf_key_hashes from EpochsStateQuery::TotalBlocksMinted
83+
pub total_blocks_minted: Vec<u64>,
84+
}

common/src/queries/pools.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ pub enum PoolsStateQuery {
1313
pools_operators: Vec<Vec<u8>>,
1414
epoch: u64,
1515
},
16-
// Get total blocks minted for each vrf vkey hashes (not included current epoch's blocks minted)
17-
GetPoolsTotalBlocksMinted {
18-
vrf_key_hashes: Vec<Vec<u8>>,
19-
},
2016
GetPoolInfo {
2117
pool_id: Vec<u8>,
2218
},
@@ -50,7 +46,6 @@ pub enum PoolsStateQueryResponse {
5046
PoolsRetiredList(PoolsRetiredList),
5147
PoolsRetiringList(PoolsRetiringList),
5248
PoolsActiveStakes(PoolsActiveStakes),
53-
PoolsTotalBlocksMinted(PoolsTotalBlocksMinted),
5449
PoolInfo(PoolInfo),
5550
PoolHistory(PoolHistory),
5651
PoolMetadata(PoolMetadata),
@@ -92,12 +87,6 @@ pub struct PoolsActiveStakes {
9287
pub total_active_stake: u64,
9388
}
9489

95-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
96-
pub struct PoolsTotalBlocksMinted {
97-
// this is in same order of vrf_key_hashes from PoolsStateQuery::GetPoolsTotalBlocksMinted
98-
pub total_blocks_minted: Vec<u64>,
99-
}
100-
10190
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
10291
pub struct PoolInfo {}
10392

modules/epoch_activity_counter/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ tracing = "0.1.40"
1919
serde = { version = "1.0.214", features = ["derive"] }
2020
serde_json = "1.0.132"
2121
hex = "0.4.3"
22+
dashmap = "6.1.0"
23+
imbl = "6.0.0"
2224

2325
[lib]
2426
path = "src/epoch_activity_counter.rs"

0 commit comments

Comments
 (0)