Skip to content

Commit

Permalink
add skip_empty_output()
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroShkvorets committed Sep 20, 2024
1 parent 0baf4bf commit e60b3dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 5 additions & 1 deletion eosmechanics/src/maps.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashSet;

use substreams::errors::Error;
use substreams::{errors::Error, skip_empty_output};
use substreams_antelope::pb::{Block, ProducerAuthoritySchedule};

use crate::eosmechanics::{ProducerUsage, ScheduleChange};
Expand Down Expand Up @@ -29,6 +29,8 @@ use crate::eosmechanics::{ProducerUsage, ScheduleChange};
/// producer.
#[substreams::handlers::map]
pub fn map_producer_usage(block: Block) -> Result<ProducerUsage, Error> {
skip_empty_output();

// Producer is found in the block header
let producer = block.header.as_ref().unwrap().producer.clone();

Expand All @@ -54,6 +56,8 @@ pub fn map_producer_usage(block: Block) -> Result<ProducerUsage, Error> {

#[substreams::handlers::map]
pub fn map_schedule_change(block: Block) -> Result<ScheduleChange, Error> {
skip_empty_output();

let active_schedule: Vec<String> = match block.proposer_policy.as_ref() {
Some(proposer_policy) => schedule_to_accounts(proposer_policy.proposer_schedule.as_ref().unwrap()), // New
None => schedule_to_accounts(block.active_schedule_v2.as_ref().unwrap()), // Old
Expand Down
10 changes: 4 additions & 6 deletions eosmechanics/src/sinks.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use std::collections::HashMap;

use substreams::errors::Error;
use substreams::log;
use substreams_sink_prometheus::{PrometheusOperations, Counter, Gauge, Histogram, Summary};
use substreams::{errors::Error, skip_empty_output};
use substreams_sink_prometheus::{Counter, Gauge, Histogram, PrometheusOperations, Summary};

use crate::eosmechanics::{ProducerUsage, ScheduleChange};

#[substreams::handlers::map]
pub fn prom_out(
producer_usage: ProducerUsage,
schedule_change: ScheduleChange
) -> Result<PrometheusOperations, Error> {
pub fn prom_out(producer_usage: ProducerUsage, schedule_change: ScheduleChange) -> Result<PrometheusOperations, Error> {
skip_empty_output();

let mut prom_out = PrometheusOperations::default();
let producer = producer_usage.producer.clone();
Expand Down

0 comments on commit e60b3dc

Please sign in to comment.