MCPcopy Create free account
hub / github.com/DNAProject/DNA / blockInfo

Function blockInfo

cmd/info_cmd.go:94–123  ·  view source on GitHub ↗
(ctx *cli.Context)

Source from the content-addressed store, hash-verified

92}
93
94func blockInfo(ctx *cli.Context) error {
95 SetRpcPort(ctx)
96 if ctx.NArg() < 1 {
97 PrintErrorMsg("Missing argument,BlockHash or height expected.")
98 cli.ShowSubcommandHelp(ctx)
99 return nil
100 }
101
102 var data []byte
103 var err error
104 var height int64
105 arg := ctx.Args().First()
106 if len(arg) > 30 {
107 data, err = utils.GetBlock(arg)
108 if err != nil {
109 return fmt.Errorf("GetBlock error:%s", err)
110 }
111 } else {
112 height, err = strconv.ParseInt(arg, 10, 64)
113 if err != nil {
114 return fmt.Errorf("arg:%s invalid block hash or block height", arg)
115 }
116 data, err = utils.GetBlock(height)
117 if err != nil {
118 return fmt.Errorf("GetBlock error:%s", err)
119 }
120 }
121 PrintJsonData(data)
122 return nil
123}
124
125func txInfo(ctx *cli.Context) error {
126 SetRpcPort(ctx)

Callers

nothing calls this directly

Calls 6

GetBlockFunction · 0.92
SetRpcPortFunction · 0.85
PrintErrorMsgFunction · 0.85
PrintJsonDataFunction · 0.85
ErrorfMethod · 0.80
FirstMethod · 0.65

Tested by

no test coverage detected