1
1
import { ReplaySubject } from 'rxjs' ;
2
2
import { distinctUntilChanged , map } from 'rxjs/operators' ;
3
3
import equal from 'fast-deep-equal' ;
4
- import Database from './database.js' ;
4
+ import Database from './database/database.js' ;
5
+ import NullDatabase from './database/nullDatabase.js' ;
5
6
import Events from 'events' ;
6
7
import Web3Eth from 'web3-eth' ;
7
8
import { isAddress } from './utils' ;
@@ -25,6 +26,7 @@ export default class Subspace {
25
26
this . options . callInterval = options . callInterval || 0 ;
26
27
this . options . dbFilename = options . dbFilename || 'subspace.db' ;
27
28
this . latestBlockNumber = undefined ;
29
+ this . disableDatabase = options . disableDatabase ;
28
30
29
31
this . newBlocksSubscription = null ;
30
32
this . intervalTracker = null ;
@@ -33,8 +35,11 @@ export default class Subspace {
33
35
34
36
init ( ) {
35
37
return new Promise ( ( resolve , reject ) => {
36
- this . _db = new Database ( this . options . dbFilename , this . events ) ;
37
- this . db = this . _db . db ;
38
+ if ( this . disableDatabase === true ) {
39
+ this . _db = new NullDatabase ( "" , this . events ) ;
40
+ } else {
41
+ this . _db = new Database ( this . options . dbFilename , this . events ) ;
42
+ }
38
43
this . eventSyncer = new EventSyncer ( this . web3 , this . events , this . _db ) ;
39
44
this . logSyncer = new LogSyncer ( this . web3 , this . events , this . _db ) ;
40
45
0 commit comments