Skip to content

Commit bc313fa

Browse files
author
Ludo Galabru
committed
feat: move thread pool size to config
1 parent 1b58ccd commit bc313fa

File tree

4 files changed

+44
-18
lines changed

4 files changed

+44
-18
lines changed

components/chainhook-cli/src/block/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct Record {
1515
pub id: u64,
1616
pub created_at: String,
1717
pub kind: RecordKind,
18-
pub raw_log: String,
18+
pub blob: Option<String>,
1919
}
2020

2121
#[derive(Debug, Deserialize)]

components/chainhook-cli/src/config/file.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ pub struct EventSourceConfigFile {
2525

2626
#[derive(Deserialize, Debug, Clone)]
2727
pub struct ChainhooksConfigFile {
28-
pub max_stacks_registrations: Option<u16>,
29-
pub max_bitcoin_registrations: Option<u16>,
28+
pub max_stacks_registrations: Option<usize>,
29+
pub max_bitcoin_registrations: Option<usize>,
30+
pub max_stacks_concurrent_scans: Option<usize>,
31+
pub max_bitcoin_concurrent_scans: Option<usize>,
3032
}
3133

3234
#[derive(Deserialize, Debug, Clone)]

components/chainhook-cli/src/config/generator.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ redis_uri = "redis://localhost:6379/"
66
cache_path = "cache"
77
88
[chainhooks]
9-
max_stacks_registrations = 500
10-
max_bitcoin_registrations = 500
9+
max_stacks_registrations = 100
10+
max_bitcoin_registrations = 100
11+
max_stacks_concurrent_scans = 10
12+
max_bitcoin_concurrent_scans = 10
1113
1214
[network]
1315
mode = "mainnet"
@@ -17,7 +19,7 @@ bitcoind_rpc_password = "devnet"
1719
stacks_node_rpc_url = "http://localhost:20443"
1820
1921
[[event_source]]
20-
tsv_file_url = "https://archive.hiro.so/mainnet/stacks-blockchain-api/mainnet-stacks-blockchain-api-latest.gz"
22+
tsv_file_url = "https://archive.hiro.so/mainnet/stacks-blockchain-api/mainnet-stacks-blockchain-api-latest"
2123
"#
2224
);
2325
return conf;

components/chainhook-cli/src/config/mod.rs

+34-12
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ use std::fs::File;
1010
use std::io::{BufReader, Read};
1111
use std::path::PathBuf;
1212

13-
use crate::service::{DEFAULT_CONTROL_PORT, DEFAULT_INGESTION_PORT};
14-
1513
const DEFAULT_MAINNET_STACKS_TSV_ARCHIVE: &str =
1614
"https://archive.hiro.so/mainnet/stacks-blockchain-api/mainnet-stacks-blockchain-api-latest";
1715
const DEFAULT_TESTNET_STACKS_TSV_ARCHIVE: &str =
1816
"https://archive.hiro.so/testnet/stacks-blockchain-api/testnet-stacks-blockchain-api-latest";
1917
const DEFAULT_MAINNET_ORDINALS_SQLITE_ARCHIVE: &str =
2018
"https://archive.hiro.so/mainnet/chainhooks/hord-latest.sqlite";
2119

20+
pub const DEFAULT_INGESTION_PORT: u16 = 20455;
21+
pub const DEFAULT_CONTROL_PORT: u16 = 20456;
22+
pub const STACKS_SCAN_THREAD_POOL_SIZE: usize = 10;
23+
pub const BITCOIN_SCAN_THREAD_POOL_SIZE: usize = 10;
24+
pub const STACKS_MAX_PREDICATE_REGISTRATION: usize = 50;
25+
pub const BITCOIN_MAX_PREDICATE_REGISTRATION: usize = 50;
26+
2227
#[derive(Clone, Debug)]
2328
pub struct Config {
2429
pub storage: StorageConfig,
@@ -70,8 +75,10 @@ pub struct UrlConfig {
7075

7176
#[derive(Clone, Debug)]
7277
pub struct ChainhooksConfig {
73-
pub max_stacks_registrations: u16,
74-
pub max_bitcoin_registrations: u16,
78+
pub max_stacks_registrations: usize,
79+
pub max_bitcoin_registrations: usize,
80+
pub max_stacks_concurrent_scans: usize,
81+
pub max_bitcoin_concurrent_scans: usize,
7582
pub enable_http_api: bool,
7683
}
7784

@@ -151,11 +158,20 @@ impl Config {
151158
max_stacks_registrations: config_file
152159
.chainhooks
153160
.max_stacks_registrations
154-
.unwrap_or(100),
161+
.unwrap_or(STACKS_MAX_PREDICATE_REGISTRATION),
155162
max_bitcoin_registrations: config_file
156163
.chainhooks
157164
.max_bitcoin_registrations
158-
.unwrap_or(100),
165+
.unwrap_or(BITCOIN_MAX_PREDICATE_REGISTRATION),
166+
max_stacks_concurrent_scans: config_file
167+
.chainhooks
168+
.max_stacks_registrations
169+
.unwrap_or(STACKS_SCAN_THREAD_POOL_SIZE),
170+
max_bitcoin_concurrent_scans: config_file
171+
.chainhooks
172+
.max_bitcoin_registrations
173+
.unwrap_or(BITCOIN_SCAN_THREAD_POOL_SIZE),
174+
159175
enable_http_api: true,
160176
},
161177
network: IndexerConfig {
@@ -344,8 +360,10 @@ impl Config {
344360
},
345361
event_sources: vec![],
346362
chainhooks: ChainhooksConfig {
347-
max_stacks_registrations: 50,
348-
max_bitcoin_registrations: 50,
363+
max_stacks_registrations: STACKS_MAX_PREDICATE_REGISTRATION,
364+
max_bitcoin_registrations: BITCOIN_MAX_PREDICATE_REGISTRATION,
365+
max_stacks_concurrent_scans: STACKS_SCAN_THREAD_POOL_SIZE,
366+
max_bitcoin_concurrent_scans: BITCOIN_SCAN_THREAD_POOL_SIZE,
349367
enable_http_api: true,
350368
},
351369
network: IndexerConfig {
@@ -374,8 +392,10 @@ impl Config {
374392
file_url: DEFAULT_TESTNET_STACKS_TSV_ARCHIVE.into(),
375393
})],
376394
chainhooks: ChainhooksConfig {
377-
max_stacks_registrations: 10,
378-
max_bitcoin_registrations: 10,
395+
max_stacks_registrations: STACKS_MAX_PREDICATE_REGISTRATION,
396+
max_bitcoin_registrations: BITCOIN_MAX_PREDICATE_REGISTRATION,
397+
max_stacks_concurrent_scans: STACKS_SCAN_THREAD_POOL_SIZE,
398+
max_bitcoin_concurrent_scans: BITCOIN_SCAN_THREAD_POOL_SIZE,
379399
enable_http_api: true,
380400
},
381401
network: IndexerConfig {
@@ -409,8 +429,10 @@ impl Config {
409429
}),
410430
],
411431
chainhooks: ChainhooksConfig {
412-
max_stacks_registrations: 10,
413-
max_bitcoin_registrations: 10,
432+
max_stacks_registrations: STACKS_MAX_PREDICATE_REGISTRATION,
433+
max_bitcoin_registrations: BITCOIN_MAX_PREDICATE_REGISTRATION,
434+
max_stacks_concurrent_scans: STACKS_SCAN_THREAD_POOL_SIZE,
435+
max_bitcoin_concurrent_scans: BITCOIN_SCAN_THREAD_POOL_SIZE,
414436
enable_http_api: true,
415437
},
416438
network: IndexerConfig {

0 commit comments

Comments
 (0)