cmd/geth, rpc/api: extend metrics API, add a basic monitor command
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"reflect"
|
||||
|
||||
"github.com/ethereum/go-ethereum/rpc/shared"
|
||||
)
|
||||
@ -45,3 +46,26 @@ func (args *WaitForBlockArgs) UnmarshalJSON(b []byte) (err error) {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type MetricsArgs struct {
|
||||
Raw bool
|
||||
}
|
||||
|
||||
func (args *MetricsArgs) UnmarshalJSON(b []byte) (err error) {
|
||||
var obj []interface{}
|
||||
if err := json.Unmarshal(b, &obj); err != nil {
|
||||
return shared.NewDecodeParamError(err.Error())
|
||||
}
|
||||
if len(obj) > 1 {
|
||||
return fmt.Errorf("metricsArgs needs 0, 1 arguments")
|
||||
}
|
||||
// default values when not provided
|
||||
if len(obj) >= 1 && obj[0] != nil {
|
||||
if value, ok := obj[0].(bool); !ok {
|
||||
return fmt.Errorf("invalid argument %v", reflect.TypeOf(obj[0]))
|
||||
} else {
|
||||
args.Raw = value
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user