forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ethereum#46 from lochjin/master
Optimize miner for qng
- Loading branch information
Showing
3 changed files
with
24 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
package miner | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/state" | ||
"github.com/ethereum/go-ethereum/core/txpool" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/holiman/uint256" | ||
"math/big" | ||
) | ||
|
||
type IMiner interface { | ||
SetExtra(extra []byte) error | ||
Pending() (*types.Block, types.Receipts, *state.StateDB) | ||
SetGasCeil(ceil uint64) | ||
SetGasTip(tip *big.Int) error | ||
BuildPayload(args *BuildPayloadArgs) (*Payload, error) | ||
} | ||
|
||
type TransactionsByPriceAndNonce interface { | ||
Peek() (*txpool.LazyTransaction, *uint256.Int) | ||
Shift() | ||
Pop() | ||
} | ||
func (payload *Payload) ResolveFullBlock() *types.Block { | ||
payload.lock.Lock() | ||
defer payload.lock.Unlock() | ||
|
||
func NewTransactionsByPriceAndNonce(signer types.Signer, txs map[common.Address][]*txpool.LazyTransaction, baseFee *big.Int) TransactionsByPriceAndNonce { | ||
return newTransactionsByPriceAndNonce(signer, txs, baseFee) | ||
if payload.full == nil { | ||
select { | ||
case <-payload.stop: | ||
return nil | ||
default: | ||
} | ||
// Wait the full payload construction. Note it might block | ||
// forever if Resolve is called in the meantime which | ||
// terminates the background construction process. | ||
payload.cond.Wait() | ||
} | ||
// Terminate the background payload construction | ||
select { | ||
case <-payload.stop: | ||
default: | ||
close(payload.stop) | ||
} | ||
return payload.full | ||
} |