@@ -49,6 +49,14 @@ lazy_static! {
49
49
. map( |s| u64 :: from_str( & s)
50
50
. unwrap_or_else( |_| panic!( "failed to parse env var ETHEREUM_ANCESTOR_COUNT" ) ) )
51
51
. unwrap_or( 50 ) ;
52
+
53
+ // Run against a read-only database. This turns off a few things:
54
+ // - Chain head listeners
55
+ // - Store events
56
+ // - Subscriptions and the WebSocket server
57
+ // - The JSON-RPC admin server
58
+ static ref EXPERIMENTAL_READONLY_DB : bool = env:: var( "GRAPH_EXPERIMENTAL_READONLY_DB" )
59
+ . ok( ) . is_some( ) ;
52
60
}
53
61
54
62
git_testament ! ( TESTAMENT ) ;
@@ -259,12 +267,6 @@ async fn main() {
259
267
. value_name ( "URL" )
260
268
. help ( "HTTP endpoint for 3box profiles" ) ,
261
269
)
262
- . arg (
263
- Arg :: with_name ( "readonly-db" )
264
- . takes_value ( false )
265
- . long ( "readonly-db" )
266
- . help ( "Run against a readonly db (no subscriptions etc.)" ) ,
267
- )
268
270
. get_matches ( ) ;
269
271
270
272
// Set up logger
@@ -502,9 +504,7 @@ async fn main() {
502
504
connection_pool_registry,
503
505
) ;
504
506
505
- let readonly_db = matches. is_present ( "readonly-db" ) ;
506
-
507
- let chain_head_update_listener = if readonly_db {
507
+ let chain_head_update_listener = if * EXPERIMENTAL_READONLY_DB {
508
508
None
509
509
} else {
510
510
Some ( Arc :: new ( PostgresChainHeadUpdateListener :: new (
@@ -514,7 +514,7 @@ async fn main() {
514
514
) ) )
515
515
} ;
516
516
517
- let subscriptions = if readonly_db {
517
+ let subscriptions = if * EXPERIMENTAL_READONLY_DB {
518
518
None
519
519
} else {
520
520
Some ( Arc :: new ( SubscriptionManager :: new (
@@ -580,7 +580,7 @@ async fn main() {
580
580
581
581
// Disable the subscriptions server when running against a read-only
582
582
// database
583
- if !readonly_db {
583
+ if !* EXPERIMENTAL_READONLY_DB {
584
584
let subscription_server = GraphQLSubscriptionServer :: new (
585
585
& logger,
586
586
graphql_runner. clone ( ) ,
@@ -598,7 +598,7 @@ async fn main() {
598
598
node_id. clone ( ) ,
599
599
) ;
600
600
601
- if !readonly_db {
601
+ if !* EXPERIMENTAL_READONLY_DB {
602
602
// Spawn Ethereum network indexers for all networks that are to be indexed
603
603
if let Some ( network_subgraphs) = matches. values_of ( "network-subgraphs" ) {
604
604
network_subgraphs
0 commit comments