Skip to content

Commit

Permalink
Merge pull request #37 from sei-protocol/genesis-export-oom
Browse files Browse the repository at this point in the history
Genesis export OOM
  • Loading branch information
jewei1997 authored Jul 29, 2024
2 parents 2ec5bce + c087f56 commit 2df970b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
22 changes: 22 additions & 0 deletions modules/apps/transfer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
return gs.Validate()
}

// ValidateGenesisStream performs genesis state validation for the ibc transfer module in a streaming fashion.
func (am AppModuleBasic) ValidateGenesisStream(cdc codec.JSONCodec, config client.TxEncodingConfig, genesisCh <-chan json.RawMessage) error {
for genesis := range genesisCh {
err := am.ValidateGenesis(cdc, config, genesis)
if err != nil {
return err
}
}
return nil
}

// RegisterRESTRoutes implements AppModuleBasic interface
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
}
Expand Down Expand Up @@ -143,6 +154,17 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
return cdc.MustMarshalJSON(gs)
}

// ExportGenesisStream returns the exported genesis state as raw bytes for the ibc-transfer module in a
// streaming fashion.
func (am AppModule) ExportGenesisStream(ctx sdk.Context, cdc codec.JSONCodec) <-chan json.RawMessage {
ch := make(chan json.RawMessage)
go func() {
ch <- am.ExportGenesis(ctx, cdc)
close(ch)
}()
return ch
}

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 2 }

Expand Down
21 changes: 21 additions & 0 deletions modules/core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
return gs.Validate()
}

func (am AppModuleBasic) ValidateGenesisStream(cdc codec.JSONCodec, config client.TxEncodingConfig, genesisCh <-chan json.RawMessage) error {
for genesis := range genesisCh {
err := am.ValidateGenesis(cdc, config, genesis)
if err != nil {
return err
}
}
return nil
}

// RegisterRESTRoutes does nothing. IBC does not support legacy REST routes.
func (AppModuleBasic) RegisterRESTRoutes(client.Context, *mux.Router) {}

Expand Down Expand Up @@ -159,6 +169,17 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
return cdc.MustMarshalJSON(ExportGenesis(ctx, *am.keeper))
}

// ExportGenesisStream returns the exported genesis state as raw bytes for the ibc
// module in a streaing fashion
func (am AppModule) ExportGenesisStream(ctx sdk.Context, cdc codec.JSONCodec) <-chan json.RawMessage {
ch := make(chan json.RawMessage)
go func() {
ch <- am.ExportGenesis(ctx, cdc)
close(ch)
}()
return ch
}

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 2 }

Expand Down

0 comments on commit 2df970b

Please sign in to comment.