miner, rpc: added submit hashrate for remote agents

This commit is contained in:
Jeffrey Wilcke
2015-08-06 11:58:14 +02:00
parent 82ef26f600
commit c32073b11f
4 changed files with 85 additions and 4 deletions

View File

@ -169,6 +169,37 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
return nil
}
type SubmitHashRateArgs struct {
Id string
Rate uint64
}
func (args *SubmitHashRateArgs) UnmarshalJSON(b []byte) (err error) {
var obj []interface{}
if err := json.Unmarshal(b, &obj); err != nil {
return shared.NewDecodeParamError(err.Error())
}
if len(obj) < 2 {
return shared.NewInsufficientParamsError(len(obj), 2)
}
arg0, ok := obj[0].(string)
if !ok {
return shared.NewInvalidTypeError("hash", "not a string")
}
args.Id = arg0
arg1, ok := obj[1].(string)
if !ok {
return shared.NewInvalidTypeError("rate", "not a string")
}
args.Rate = common.String2Big(arg1).Uint64()
return nil
}
type HashArgs struct {
Hash string
}