@@ -28,7 +28,6 @@ import (
2828 "github.com/ethereum/go-ethereum/common/hexutil"
2929 "github.com/ethereum/go-ethereum/common/math"
3030 "github.com/ethereum/go-ethereum/consensus/clique"
31- "github.com/ethereum/go-ethereum/consensus/ethash"
3231 "github.com/ethereum/go-ethereum/core/types"
3332 "github.com/ethereum/go-ethereum/crypto"
3433 "github.com/ethereum/go-ethereum/log"
@@ -74,11 +73,9 @@ type bbInput struct {
7473 Withdrawals []* types.Withdrawal `json:"withdrawals,omitempty"`
7574 Clique * cliqueInput `json:"clique,omitempty"`
7675
77- Ethash bool `json:"-"`
78- EthashDir string `json:"-"`
79- PowMode ethash.Mode `json:"-"`
80- Txs []* types.Transaction `json:"-"`
81- Ommers []* types.Header `json:"-"`
76+ Ethash bool `json:"-"`
77+ Txs []* types.Transaction `json:"-"`
78+ Ommers []* types.Header `json:"-"`
8279}
8380
8481type cliqueInput struct {
@@ -162,42 +159,13 @@ func (i *bbInput) ToBlock() *types.Block {
162159// SealBlock seals the given block using the configured engine.
163160func (i * bbInput ) SealBlock (block * types.Block ) (* types.Block , error ) {
164161 switch {
165- case i .Ethash :
166- return i .sealEthash (block )
167162 case i .Clique != nil :
168163 return i .sealClique (block )
169164 default :
170165 return block , nil
171166 }
172167}
173168
174- // sealEthash seals the given block using ethash.
175- func (i * bbInput ) sealEthash (block * types.Block ) (* types.Block , error ) {
176- if i .Header .Nonce != nil {
177- return nil , NewError (ErrorConfig , fmt .Errorf ("sealing with ethash will overwrite provided nonce" ))
178- }
179- ethashConfig := ethash.Config {
180- PowMode : i .PowMode ,
181- DatasetDir : i .EthashDir ,
182- CacheDir : i .EthashDir ,
183- DatasetsInMem : 1 ,
184- DatasetsOnDisk : 2 ,
185- CachesInMem : 2 ,
186- CachesOnDisk : 3 ,
187- }
188- engine := ethash .New (ethashConfig , nil , true )
189- defer engine .Close ()
190- // Use a buffered chan for results.
191- // If the testmode is used, the sealer will return quickly, and complain
192- // "Sealing result is not read by miner" if it cannot write the result.
193- results := make (chan * types.Block , 1 )
194- if err := engine .Seal (nil , block , results , nil ); err != nil {
195- panic (fmt .Sprintf ("failed to seal block: %v" , err ))
196- }
197- found := <- results
198- return block .WithSeal (found .Header ()), nil
199- }
200-
201169// sealClique seals the given block using clique.
202170func (i * bbInput ) sealClique (block * types.Block ) (* types.Block , error ) {
203171 // If any clique value overwrites an explicit header value, fail
@@ -267,28 +235,8 @@ func readInput(ctx *cli.Context) (*bbInput, error) {
267235 withdrawalsStr = ctx .String (InputWithdrawalsFlag .Name )
268236 txsStr = ctx .String (InputTxsRlpFlag .Name )
269237 cliqueStr = ctx .String (SealCliqueFlag .Name )
270- ethashOn = ctx .Bool (SealEthashFlag .Name )
271- ethashDir = ctx .String (SealEthashDirFlag .Name )
272- ethashMode = ctx .String (SealEthashModeFlag .Name )
273238 inputData = & bbInput {}
274239 )
275- if ethashOn && cliqueStr != "" {
276- return nil , NewError (ErrorConfig , fmt .Errorf ("both ethash and clique sealing specified, only one may be chosen" ))
277- }
278- if ethashOn {
279- inputData .Ethash = ethashOn
280- inputData .EthashDir = ethashDir
281- switch ethashMode {
282- case "normal" :
283- inputData .PowMode = ethash .ModeNormal
284- case "test" :
285- inputData .PowMode = ethash .ModeTest
286- case "fake" :
287- inputData .PowMode = ethash .ModeFake
288- default :
289- return nil , NewError (ErrorConfig , fmt .Errorf ("unknown pow mode: %s, supported modes: test, fake, normal" , ethashMode ))
290- }
291- }
292240 if headerStr == stdinSelector || ommersStr == stdinSelector || txsStr == stdinSelector || cliqueStr == stdinSelector {
293241 decoder := json .NewDecoder (os .Stdin )
294242 if err := decoder .Decode (inputData ); err != nil {
0 commit comments