mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Merge pull request #231 from nguyenbatam/move_subscribeTx_subscribeSpecialTx
move from Subscribe Tx to Subscribe Special Tx in Double Validate
This commit is contained in:
commit
996f8580df
7 changed files with 16 additions and 13 deletions
|
|
@ -366,7 +366,7 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis {
|
|||
common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd
|
||||
common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul
|
||||
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing
|
||||
faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))},
|
||||
faucet: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ var (
|
|||
|
||||
ErrZeroGasPrice = errors.New("zero gas price")
|
||||
|
||||
ErrDuplicateSpecialTransaction = errors.New("duplicate a specail transaction")
|
||||
ErrDuplicateSpecialTransaction = errors.New("duplicate a special transaction")
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -192,6 +192,9 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
// Hook double validation
|
||||
doubleValidateHook := func(block *types.Block) error {
|
||||
parentBlk := eth.blockchain.GetBlockByHash(block.ParentHash())
|
||||
if parentBlk == nil {
|
||||
return fmt.Errorf("Fail to get parent block for hash: %v", block.ParentHash())
|
||||
}
|
||||
snap, err := c.GetSnapshot(eth.blockchain, parentBlk.Header())
|
||||
if err != nil {
|
||||
if err == consensus.ErrUnknownAncestor {
|
||||
|
|
@ -205,6 +208,9 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
return fmt.Errorf("Fail to validate M2 condition for importing block: %v", err)
|
||||
}
|
||||
if eth.etherbase != m2 {
|
||||
txCh := make(chan core.TxPreEvent, txChanSize)
|
||||
subEvent := eth.txPool.SubscribeSpecialTxPreEvent(txCh)
|
||||
defer subEvent.Unsubscribe()
|
||||
// firstly, look into pending txPool
|
||||
pendingMap, err := eth.txPool.Pending()
|
||||
if err != nil {
|
||||
|
|
@ -221,8 +227,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
}
|
||||
}
|
||||
//then wait until signTx from m2 comes into txPool
|
||||
txCh := make(chan core.TxPreEvent, txChanSize)
|
||||
subEvent := eth.txPool.SubscribeTxPreEvent(txCh)
|
||||
select {
|
||||
case event := <-txCh:
|
||||
from, err := eth.txPool.GetSender(event.Tx)
|
||||
|
|
@ -233,7 +237,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
case <-time.After(time.Duration(10) * time.Second):
|
||||
return fmt.Errorf("Time out waiting for confirmation from m2")
|
||||
}
|
||||
subEvent.Unsubscribe()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ type PublicDownloaderAPI struct {
|
|||
// installSyncSubscription channel.
|
||||
func NewPublicDownloaderAPI(d *Downloader, m *event.TypeMux) *PublicDownloaderAPI {
|
||||
api := &PublicDownloaderAPI{
|
||||
d: d,
|
||||
mux: m,
|
||||
d: d,
|
||||
mux: m,
|
||||
installSyncSubscription: make(chan chan interface{}),
|
||||
uninstallSyncSubscription: make(chan *uninstallSyncSubscriptionRequest),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,10 +242,10 @@ func testGetBlockBodies(t *testing.T, protocol int) {
|
|||
available []bool // Availability of explicitly requested blocks
|
||||
expected int // Total number of existing blocks to expect
|
||||
}{
|
||||
{1, nil, nil, 1}, // A single random block should be retrievable
|
||||
{10, nil, nil, 10}, // Multiple random blocks should be retrievable
|
||||
{limit, nil, nil, limit}, // The maximum possible blocks should be retrievable
|
||||
{limit + 1, nil, nil, limit}, // No more than the possible block count should be returned
|
||||
{1, nil, nil, 1}, // A single random block should be retrievable
|
||||
{10, nil, nil, 10}, // Multiple random blocks should be retrievable
|
||||
{limit, nil, nil, limit}, // The maximum possible blocks should be retrievable
|
||||
{limit + 1, nil, nil, limit}, // No more than the possible block count should be returned
|
||||
{0, []common.Hash{pm.blockchain.Genesis().Hash()}, []bool{true}, 1}, // The genesis block should be retrievable
|
||||
{0, []common.Hash{pm.blockchain.CurrentBlock().Hash()}, []bool{true}, 1}, // The chains head block should be retrievable
|
||||
{0, []common.Hash{{}}, []bool{false}, 0}, // A non existent block should not be returned
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ func (t *dialTask) Do(srv *Server) {
|
|||
}
|
||||
}
|
||||
if err == nil {
|
||||
log.Trace("Dial pair connection sucess", "task", t.dest)
|
||||
log.Trace("Dial pair connection success", "task", t.dest)
|
||||
} else {
|
||||
log.Trace("Dial pair connection error", "task", t.dest, "err", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ func initErrHandling() {
|
|||
multipleChoicesPage := GetMultipleChoicesErrorPage()
|
||||
//map the codes to the available pages
|
||||
tnames := map[int]string{
|
||||
0: genErrPage, //default
|
||||
0: genErrPage, //default
|
||||
http.StatusBadRequest: genErrPage,
|
||||
http.StatusNotFound: notFoundPage,
|
||||
http.StatusMultipleChoices: multipleChoicesPage,
|
||||
|
|
|
|||
Loading…
Reference in a new issue