Skip to content

Commit bbb8be6

Browse files
musitdevnicholasflintwillow
authored andcommitted
feat: Add ans processor (#1081)
1 parent 9dbb761 commit bbb8be6

File tree

1 file changed

+20
-10
lines changed
  • networks/movement/indexer/src

1 file changed

+20
-10
lines changed

networks/movement/indexer/src/main.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ fn main() -> Result<(), anyhow::Error> {
5858
None
5959
};
6060

61+
// ANS processor.
62+
let ans_indexer_config = build_processor_conf(
63+
"ans_processor
64+
ans_v1_primary_names_table_handle: temp
65+
ans_v1_name_records_table_handle: temp
66+
ans_v2_contract_address: 0x67bf15b3eed0fc62deea9630bbbd1d48842550655140f913699a1ca7e6f727d8",
67+
&maptos_config,
68+
)?;
69+
6170
let num_cpus = num_cpus::get();
6271
let worker_threads = (num_cpus * RUNTIME_WORKER_MULTIPLIER).max(16);
6372
println!(
@@ -94,6 +103,7 @@ fn main() -> Result<(), anyhow::Error> {
94103
set.spawn(async move { token_indexer_config.run().await });
95104
set.spawn(async move { tokenv2_indexer_config.run().await });
96105
}
106+
set.spawn(async move { ans_indexer_config.run().await });
97107

98108
while let Some(res) = set.join_next().await {
99109
tracing::error!("An Error occurs during indexer execution: {res:?}");
@@ -122,33 +132,33 @@ fn build_processor_conf(
122132
.map(|t| t.parse().unwrap_or(10))
123133
.unwrap_or(10);
124134

125-
// If the starting version is not defined, don't put a default value in the conf.
126-
let starting_version_entry = std::env::var("INDEXER_STARTING_VERSION")
127-
.map(|t| t.parse().unwrap_or(0))
128-
.map(|t| format!("starting_version: {}", t))
129-
.unwrap_or(String::new());
130-
131135
//create config file
132-
let indexer_config_content = format!(
136+
let mut indexer_config_content = format!(
133137
"processor_config:
134138
type: {}
135139
postgres_connection_string: {}
136140
indexer_grpc_data_service_address: {}
137141
indexer_grpc_http2_ping_interval_in_secs: {}
138142
indexer_grpc_http2_ping_timeout_in_secs: {}
139143
auth_token: \"{}\"
140-
default_sleep_time_between_request: {}
141-
{}",
144+
default_sleep_time_between_request: {}",
142145
processor_name,
143146
maptos_config.indexer_processor.postgres_connection_string,
144147
indexer_grpc_data_service_address,
145148
maptos_config.indexer.maptos_indexer_grpc_inactivity_timeout,
146149
maptos_config.indexer.maptos_indexer_grpc_inactivity_ping_interval,
147150
maptos_config.indexer_processor.indexer_processor_auth_token,
148151
default_sleep_time_between_request,
149-
starting_version_entry,
150152
);
151153

154+
// If the starting version is not defined, don't put a default value in the conf.
155+
if let Ok(start_version) = std::env::var("INDEXER_STARTING_VERSION") {
156+
if let Ok(start_version) = start_version.parse::<u64>() {
157+
indexer_config_content.push('\n');
158+
indexer_config_content.push_str(&format!("starting_version: {}", start_version));
159+
}
160+
}
161+
152162
//let indexer_config_path = dot_movement.get_path().join("indexer_config.yaml");
153163
let mut output_file = tempfile::NamedTempFile::new()?;
154164
write!(output_file, "{}", indexer_config_content)?;

0 commit comments

Comments
 (0)