5
5
"net/http"
6
6
"os"
7
7
"path/filepath"
8
+ "sync"
8
9
9
10
"github.com/crypto-org-chain/cronos/x/cronos/middleware"
10
11
@@ -19,11 +20,13 @@ import (
19
20
dbm "github.com/tendermint/tm-db"
20
21
21
22
"github.com/cosmos/cosmos-sdk/baseapp"
23
+ "github.com/cosmos/cosmos-sdk/client/flags"
22
24
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
23
25
"github.com/cosmos/cosmos-sdk/codec"
24
26
"github.com/cosmos/cosmos-sdk/server/api"
25
27
"github.com/cosmos/cosmos-sdk/server/config"
26
28
servertypes "github.com/cosmos/cosmos-sdk/server/types"
29
+ "github.com/cosmos/cosmos-sdk/store/streaming/file"
27
30
storetypes "github.com/cosmos/cosmos-sdk/store/types"
28
31
"github.com/cosmos/cosmos-sdk/testutil/testdata"
29
32
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -118,6 +121,7 @@ import (
118
121
gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types"
119
122
120
123
// this line is used by starport scaffolding # stargate/app/moduleImport
124
+ cronosappclient "github.com/crypto-org-chain/cronos/client"
121
125
"github.com/crypto-org-chain/cronos/x/cronos"
122
126
cronosclient "github.com/crypto-org-chain/cronos/x/cronos/client"
123
127
cronoskeeper "github.com/crypto-org-chain/cronos/x/cronos/keeper"
@@ -142,6 +146,8 @@ const (
142
146
//
143
147
// NOTE: In the SDK, the default value is 255.
144
148
AddrLen = 20
149
+
150
+ FileStreamerDirectory = "file_streamer"
145
151
)
146
152
147
153
// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
@@ -341,6 +347,32 @@ func New(
341
347
tkeys := sdk .NewTransientStoreKeys (paramstypes .TStoreKey , evmtypes .TransientKey , feemarkettypes .TransientKey )
342
348
memKeys := sdk .NewMemoryStoreKeys (capabilitytypes .MemStoreKey )
343
349
350
+ // configure state listening capabilities using AppOptions
351
+ // we are doing nothing with the returned streamingServices and waitGroup in this case
352
+ // Only support file streamer right now.
353
+ if cast .ToString (appOpts .Get (cronosappclient .FlagStreamers )) == "file" {
354
+ streamingDir := filepath .Join (cast .ToString (appOpts .Get (flags .FlagHome )), "data" , FileStreamerDirectory )
355
+ if err := os .MkdirAll (streamingDir , os .ModePerm ); err != nil {
356
+ panic (err )
357
+ }
358
+
359
+ // default to exposing all
360
+ exposeStoreKeys := make ([]storetypes.StoreKey , 0 , len (keys ))
361
+ for _ , storeKey := range keys {
362
+ exposeStoreKeys = append (exposeStoreKeys , storeKey )
363
+ }
364
+ service , err := file .NewStreamingService (streamingDir , "" , exposeStoreKeys , appCodec )
365
+ if err != nil {
366
+ panic (err )
367
+ }
368
+ bApp .SetStreamingService (service )
369
+
370
+ wg := new (sync.WaitGroup )
371
+ if err := service .Stream (wg ); err != nil {
372
+ panic (err )
373
+ }
374
+ }
375
+
344
376
app := & App {
345
377
BaseApp : bApp ,
346
378
cdc : cdc ,
0 commit comments