diff options
author | Martin Holst Swende <martin@swende.se> | 2017-06-22 16:14:31 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-06-23 01:36:07 +0800 |
commit | b0b3cf2eeb74e45b373d4708375e899688c7f9c8 (patch) | |
tree | b1d873a6d81078c516837f9a7a77aff017d72526 /core/tx_pool.go | |
parent | 58a1e13e6dd7f52a1d5e67bee47d23fd6cfdee5c (diff) | |
download | dexon-b0b3cf2eeb74e45b373d4708375e899688c7f9c8.tar dexon-b0b3cf2eeb74e45b373d4708375e899688c7f9c8.tar.gz dexon-b0b3cf2eeb74e45b373d4708375e899688c7f9c8.tar.bz2 dexon-b0b3cf2eeb74e45b373d4708375e899688c7f9c8.tar.lz dexon-b0b3cf2eeb74e45b373d4708375e899688c7f9c8.tar.xz dexon-b0b3cf2eeb74e45b373d4708375e899688c7f9c8.tar.zst dexon-b0b3cf2eeb74e45b373d4708375e899688c7f9c8.zip |
core: add testcase for txpool
Diffstat (limited to 'core/tx_pool.go')
-rw-r--r-- | core/tx_pool.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/tx_pool.go b/core/tx_pool.go index 04ffa8a98..86a2ed232 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -301,6 +301,19 @@ func (pool *TxPool) Stats() (int, int) { return pool.stats() } +// validateInternals checks if the content in pool.all +// is consistent with the numbers reported in pending and queued +func (pool *TxPool) validateInternals() error { + pool.mu.RLock() + defer pool.mu.RUnlock() + p, q := pool.stats() + a := len(pool.all) + if a != p+q { + return fmt.Errorf("Pool.all size %d != %d pending + %d queued", a, p, q) + } + return nil +} + // stats retrieves the current pool stats, namely the number of pending and the // number of queued (non-executable) transactions. func (pool *TxPool) stats() (int, int) { |