mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
move from SubscribeTx to Subscribe Special Tx in Double Validate
This commit is contained in:
parent
3b4106fc12
commit
1afaa5f89e
7 changed files with 16 additions and 13 deletions
|
|
@ -81,7 +81,7 @@ var (
|
||||||
|
|
||||||
ErrZeroGasPrice = errors.New("zero gas price")
|
ErrZeroGasPrice = errors.New("zero gas price")
|
||||||
|
|
||||||
ErrDuplicateSpecialTransaction = errors.New("duplicate a specail transaction")
|
ErrDuplicateSpecialTransaction = errors.New("duplicate a special transaction")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,9 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||||
// Hook double validation
|
// Hook double validation
|
||||||
doubleValidateHook := func(block *types.Block) error {
|
doubleValidateHook := func(block *types.Block) error {
|
||||||
parentBlk := eth.blockchain.GetBlockByHash(block.ParentHash())
|
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())
|
snap, err := c.GetSnapshot(eth.blockchain, parentBlk.Header())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == consensus.ErrUnknownAncestor {
|
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)
|
return fmt.Errorf("Fail to validate M2 condition for importing block: %v", err)
|
||||||
}
|
}
|
||||||
if eth.etherbase != m2 {
|
if eth.etherbase != m2 {
|
||||||
|
txCh := make(chan core.TxPreEvent, txChanSize)
|
||||||
|
subEvent := eth.txPool.SubscribeSpecialTxPreEvent(txCh)
|
||||||
|
defer subEvent.Unsubscribe()
|
||||||
// firstly, look into pending txPool
|
// firstly, look into pending txPool
|
||||||
pendingMap, err := eth.txPool.Pending()
|
pendingMap, err := eth.txPool.Pending()
|
||||||
if err != nil {
|
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
|
//then wait until signTx from m2 comes into txPool
|
||||||
txCh := make(chan core.TxPreEvent, txChanSize)
|
|
||||||
subEvent := eth.txPool.SubscribeTxPreEvent(txCh)
|
|
||||||
select {
|
select {
|
||||||
case event := <-txCh:
|
case event := <-txCh:
|
||||||
from, err := eth.txPool.GetSender(event.Tx)
|
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):
|
case <-time.After(time.Duration(10) * time.Second):
|
||||||
return fmt.Errorf("Time out waiting for confirmation from m2")
|
return fmt.Errorf("Time out waiting for confirmation from m2")
|
||||||
}
|
}
|
||||||
subEvent.Unsubscribe()
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ func (t *dialTask) Do(srv *Server) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Trace("Dial pair connection sucess", "task", t.dest)
|
log.Trace("Dial pair connection success", "task", t.dest)
|
||||||
} else {
|
} else {
|
||||||
log.Trace("Dial pair connection error", "task", t.dest, "err", err)
|
log.Trace("Dial pair connection error", "task", t.dest, "err", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue