mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
Merge b84e7d07d1 into c72f5459ac
This commit is contained in:
commit
becfc64f30
2 changed files with 17 additions and 0 deletions
|
|
@ -939,6 +939,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
|
|||
if glog.V(logger.Debug) {
|
||||
glog.Infof("[%v] inserted block #%d (%d TXs %v G %d UNCs) (%x...). Took %v\n", time.Now().UnixNano(), block.Number(), len(block.Transactions()), block.GasUsed(), len(block.Uncles()), block.Hash().Bytes()[0:4], time.Since(bstart))
|
||||
}
|
||||
blockInsertTimer.UpdateSince(bstart)
|
||||
events = append(events, ChainEvent{block, block.Hash(), logs})
|
||||
|
||||
// This puts transactions in a extra db for rpc
|
||||
|
|
@ -957,6 +958,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
|
|||
if glog.V(logger.Detail) {
|
||||
glog.Infof("inserted forked block #%d (TD=%v) (%d TXs %d UNCs) (%x...). Took %v\n", block.Number(), block.Difficulty(), len(block.Transactions()), len(block.Uncles()), block.Hash().Bytes()[0:4], time.Since(bstart))
|
||||
}
|
||||
blockInsertTimer.UpdateSince(bstart)
|
||||
events = append(events, ChainSideEvent{block, logs})
|
||||
|
||||
case SplitStatTy:
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/logger/glog"
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
|
||||
)
|
||||
|
||||
|
|
@ -55,6 +56,15 @@ var (
|
|||
evictionInterval = time.Minute // Time interval to check for evictable transactions
|
||||
)
|
||||
|
||||
var (
|
||||
// Metrics
|
||||
pendingDiscardMeter = metrics.NewMeter("core/txpool/transactions/pending/discard")
|
||||
pendingReplaceMeter = metrics.NewMeter("core/txpool/transactions/pending/replace")
|
||||
queuedDiscardMeter = metrics.NewMeter("core/txpool/transactions/queued/discard")
|
||||
queuedReplaceMeter = metrics.NewMeter("core/txpool/transactions/queued/replace")
|
||||
invalidTxMeter = metrics.NewMeter("core/txpool/transactions/invalid")
|
||||
)
|
||||
|
||||
type stateFn func() (*state.StateDB, error)
|
||||
|
||||
// TxPool contains all currently known transactions. Transactions
|
||||
|
|
@ -306,6 +316,7 @@ func (pool *TxPool) add(tx *types.Transaction) error {
|
|||
}
|
||||
// Otherwise ensure basic validation passes and queue it up
|
||||
if err := pool.validateTx(tx); err != nil {
|
||||
invalidTxMeter.Mark(1)
|
||||
return err
|
||||
}
|
||||
pool.enqueueTx(hash, tx)
|
||||
|
|
@ -333,11 +344,13 @@ func (pool *TxPool) enqueueTx(hash common.Hash, tx *types.Transaction) {
|
|||
}
|
||||
inserted, old := pool.queue[from].Add(tx)
|
||||
if !inserted {
|
||||
queuedDiscardMeter.Mark(1)
|
||||
return // An older transaction was better, discard this
|
||||
}
|
||||
// Discard any previous transaction and mark this
|
||||
if old != nil {
|
||||
delete(pool.all, old.Hash())
|
||||
queuedReplaceMeter.Mark(1)
|
||||
}
|
||||
pool.all[hash] = tx
|
||||
}
|
||||
|
|
@ -360,11 +373,13 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
|
|||
if !inserted {
|
||||
// An older transaction was better, discard this
|
||||
delete(pool.all, hash)
|
||||
pendingDiscardMeter.Mark(1)
|
||||
return
|
||||
}
|
||||
// Otherwise discard any previous transaction and mark this
|
||||
if old != nil {
|
||||
delete(pool.all, old.Hash())
|
||||
pendingReplaceMeter.Mark(1)
|
||||
}
|
||||
pool.all[hash] = tx // Failsafe to work around direct pending inserts (tests)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue