Skip to content

Commit fe7ff8c

Browse files
Move the poller logic to a separate module
1 parent 891e5a5 commit fe7ff8c

File tree

21 files changed

+163
-52
lines changed

21 files changed

+163
-52
lines changed

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,16 @@ agg_mode_run_migrations: agg_mode_docker_up
315315
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin migrate -- postgres://postgres:postgres@localhost:5435/
316316

317317
agg_mode_batcher_start_local: agg_mode_run_migrations
318-
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin agg_mode_batcher -- config-files/config-agg-mode-batcher.yaml
318+
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin batcher_server -- config-files/config-agg-mode-batcher.yaml
319319

320320
agg_mode_batcher_start_ethereum_package: agg_mode_run_migrations
321-
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin agg_mode_batcher -- config-files/config-agg-mode-batcher-ethereum-package.yaml
321+
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin batcher_server -- config-files/config-agg-mode-batcher-ethereum-package.yaml
322+
323+
agg_mode_batcher_poller_start_local: agg_mode_run_migrations
324+
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin agg_mode_batcher_poller -- config-files/config-agg-mode-batcher.yaml
325+
326+
agg_mode_batcher_poller_start_ethereum_package: agg_mode_run_migrations
327+
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin agg_mode_batcher_poller -- config-files/config-agg-mode-batcher-ethereum-package.yaml
322328

323329
__AGGREGATOR__: ## ____
324330

aggregation_mode/Cargo.lock

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aggregation_mode/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "2"
3-
members = ["./batcher", "./proof_aggregator", "./db"]
3+
members = ["./batcher_server", "./proof_aggregator", "./db", "./payments_poller"]
44

55
[workspace.package]
66
version = "0.1.0"

aggregation_mode/batcher/src/lib.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

aggregation_mode/batcher/src/poller/mod.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

aggregation_mode/batcher/Cargo.toml renamed to aggregation_mode/batcher_server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "agg_mode_batcher"
2+
name = "batcher_server"
33
version = "0.1.0"
44
edition = "2021"
55

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::{fs::File, io::Read};
2+
3+
use serde::{Deserialize, Serialize};
4+
5+
#[derive(Clone, Debug, Deserialize, Serialize)]
6+
pub struct Config {
7+
pub port: u16,
8+
pub db_connection_url: String,
9+
}
10+
11+
impl Config {
12+
pub fn from_file(file_path: &str) -> Result<Config, Box<dyn std::error::Error>> {
13+
let mut file = File::open(file_path)?;
14+
let mut contents = String::new();
15+
file.read_to_string(&mut contents)?;
16+
let config: Config = serde_yaml::from_str(&contents)?;
17+
Ok(config)
18+
}
19+
}
Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,6 @@ impl Db {
7272
.await
7373
}
7474

75-
pub async fn insert_payment_event(
76-
&self,
77-
address: &str,
78-
started_at: &BigDecimal,
79-
amount: &BigDecimal,
80-
valid_until: &BigDecimal,
81-
tx_hash: &str,
82-
) -> Result<(), sqlx::Error> {
83-
sqlx::query(
84-
"INSERT INTO payment_events (address, started_at, amount, valid_until, tx_hash)
85-
VALUES ($1, $2, $3, $4, $5)
86-
ON CONFLICT (tx_hash) DO NOTHING",
87-
)
88-
.bind(address.to_lowercase())
89-
.bind(started_at)
90-
.bind(amount)
91-
.bind(valid_until)
92-
.bind(tx_hash)
93-
.execute(&self.pool)
94-
.await
95-
.map(|_| ())
96-
}
97-
9875
pub async fn has_active_payment_event(
9976
&self,
10077
address: &str,
File renamed without changes.

aggregation_mode/batcher/src/server/http.rs renamed to aggregation_mode/batcher_server/src/http.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ use super::{
1818
use crate::{
1919
config::Config,
2020
db::Db,
21-
server::types::{
22-
SubmitProofRequest, SubmitProofRequestMessageRisc0, SubmitProofRequestMessageSP1,
23-
},
21+
types::{SubmitProofRequest, SubmitProofRequestMessageRisc0, SubmitProofRequestMessageSP1},
2422
};
2523

2624
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)