refactor(era): add new flag incltx to era

This commit is contained in:
lfz941 2025-03-11 08:47:58 +08:00
parent 4cdd7c8631
commit 46dd32affe
No known key found for this signature in database
GPG key ID: 845EF1C393464698

View file

@ -55,9 +55,13 @@ var (
Usage: "number of blocks per era", Usage: "number of blocks per era",
Value: era.MaxEra1Size, Value: era.MaxEra1Size,
} }
inclTxsFlag = &cli.BoolFlag{
Name: "incltx",
Usage: "include transaction field",
}
txsFlag = &cli.BoolFlag{ txsFlag = &cli.BoolFlag{
Name: "txs", Name: "txs",
Usage: "print full transaction values", Usage: "print full transaction values. only valid when incltx is true",
} }
) )
@ -68,6 +72,7 @@ var (
ArgsUsage: "<number>", ArgsUsage: "<number>",
Action: block, Action: block,
Flags: []cli.Flag{ Flags: []cli.Flag{
inclTxsFlag,
txsFlag, txsFlag,
}, },
} }
@ -122,7 +127,7 @@ func block(ctx *cli.Context) error {
return fmt.Errorf("error reading block %d: %w", num, err) return fmt.Errorf("error reading block %d: %w", num, err)
} }
// Convert block to JSON and print. // Convert block to JSON and print.
val := ethapi.RPCMarshalBlock(block, ctx.Bool(txsFlag.Name), ctx.Bool(txsFlag.Name), params.MainnetChainConfig) val := ethapi.RPCMarshalBlock(block, ctx.Bool(inclTxsFlag.Name), ctx.Bool(txsFlag.Name), params.MainnetChainConfig)
b, err := json.MarshalIndent(val, "", " ") b, err := json.MarshalIndent(val, "", " ")
if err != nil { if err != nil {
return fmt.Errorf("error marshaling json: %w", err) return fmt.Errorf("error marshaling json: %w", err)