params: reduce extra data to 32 bytes

This commit is contained in:
Jeffrey Wilcke
2015-07-26 12:24:52 +02:00
parent 73a576c9af
commit 1e241e84f7
3 changed files with 13 additions and 4 deletions

View File

@ -17,9 +17,12 @@
package api
import (
"fmt"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
)
@ -122,6 +125,11 @@ func (self *minerApi) SetExtra(req *shared.Request) (interface{}, error) {
if err := self.codec.Decode(req.Params, &args); err != nil {
return nil, err
}
if uint64(len(args.Data)) > params.MaximumExtraDataSize.Uint64()*2 {
return false, fmt.Errorf("extra datasize can be no longer than %v bytes", params.MaximumExtraDataSize)
}
self.ethereum.Miner().SetExtra([]byte(args.Data))
return true, nil
}