mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
Use EmitUnpopulated so that kaspactl prints all fields, even the default ones (#1561)
Co-authored-by: Elichai Turkel <elichai.turkel@gmail.com>
This commit is contained in:
parent
103edf97d0
commit
df19bdfaf3
@ -2,10 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/server/grpcserver/protowire"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/server/grpcserver/protowire"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
"google.golang.org/protobuf/encoding/protojson"
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ func postCommand(cfg *configFlags, client *grpcclient.GRPCClient, responseChan c
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
printErrorAndExit(fmt.Sprintf("error posting the request to the RPC server: %s", err))
|
printErrorAndExit(fmt.Sprintf("error posting the request to the RPC server: %s", err))
|
||||||
}
|
}
|
||||||
responseBytes, err := protojson.Marshal(response)
|
responseBytes, err := protojson.MarshalOptions{EmitUnpopulated: true}.Marshal(response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
printErrorAndExit(errors.Wrapf(err, "error parsing the response from the RPC server").Error())
|
printErrorAndExit(errors.Wrapf(err, "error parsing the response from the RPC server").Error())
|
||||||
}
|
}
|
||||||
@ -92,6 +93,7 @@ func prettifyResponse(response string) string {
|
|||||||
|
|
||||||
marshalOptions := &protojson.MarshalOptions{}
|
marshalOptions := &protojson.MarshalOptions{}
|
||||||
marshalOptions.Indent = " "
|
marshalOptions.Indent = " "
|
||||||
|
marshalOptions.EmitUnpopulated = true
|
||||||
return marshalOptions.Format(kaspadMessage)
|
return marshalOptions.Format(kaspadMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ func (c *GRPCClient) PostJSON(requestJSON string) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
responseBytes, err := protojson.Marshal(response)
|
responseBytes, err := protojson.MarshalOptions{EmitUnpopulated: true}.Marshal(response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrapf(err, "error parsing the response from the RPC server")
|
return "", errors.Wrapf(err, "error parsing the response from the RPC server")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user