thegraph-runtime: Check if EthereumEvent is removed in RuntimeHost
@@ -9,7 +9,7 @@ use uuid::Uuid;
use thegraph::components::data_sources::RuntimeHostEvent;
use thegraph::components::ethereum::*;
-use thegraph::data::data_sources::DataSet;
+use thegraph::data::data_sources::{DataSet, MappingEventHandler};
use thegraph::prelude::{
RuntimeHost as RuntimeHostTrait, RuntimeHostBuilder as RuntimeHostBuilderTrait, *,
};
@@ -225,7 +225,8 @@ impl RuntimeHost {
.for_each(move |event| {
info!(event_logger, "Ethereum event received");
- let event_handler = dataset
+ let event_handler = match event.removed {
+ false => dataset
.mapping
.event_handlers
.iter()
@@ -233,7 +234,15 @@ impl RuntimeHost {
util::ethereum::string_to_h256(event_handler.event.as_str())
== event.event_signature
})
- .expect("Received an Ethereum event not mentioned in the data set");
+ .expect("Received an Ethereum event not mentioned in the data set")
+ .to_owned(),
+ true => {
+ (MappingEventHandler {
+ event: "event_removed".to_owned(),
+ handler: "reorg_handler".to_owned(),
+ }.to_owned())
+ }
+ };
debug!(event_logger, " Call event handler";
"name" => &event_handler.handler);
