func (m *txSortedMap) ReadyN(start uint64, count int) types.Transactions {
	if m.index.Len() == 0 || (*m.index)[0] > start || count <= 0 {
		return nil
	}
	var ready types.Transactions
	for next := (*m.index)[0]; m.index.Len() > 0 && (*m.index)[0] == next; next++ {
		ready = append(ready, m.items[next])
		delete(m.items, next)
		heap.Pop(m.index)
		if ready.Len() == count {
			break
		}
	}
	m.cache = nil
	return ready
}
the func is like ready, but it only retrieves up to N(count) txs that are ready
package evm
import (
	"container/heap"
	"errors"
	"fmt"
	"sort"
	"github.com/dappledger/AnnChain/eth/core/types"
)
type txSortedMap struct {
	items map[uint64]*types.Transaction  
	index *nonceHeap                     
	cache types.Transactions             
}
type nonceHeap []uint64
func (h nonceHeap) Len() int           { return len(h) }
func (h nonceHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h nonceHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *nonceHeap) Push(x interface{}) {
	*h = append(*h, x.(uint64))
}
func (h *nonceHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}
func newTxSortedMap() *txSortedMap {
	return &txSortedMap{
		items: make(map[uint64]*types.Transaction),
		index: new(nonceHeap),
	}
}
func (m *txSortedMap) Add(tx *types.Transaction) error {
	if _, exist := m.items[tx.Nonce()]; exist {
		return errors.New("tx nonce already exist in cache")
	}
	m.Put(tx)
	return nil
}
func (m *txSortedMap) Get(nonce uint64) *types.Transaction {
	return m.items[nonce]
}
func (m *txSortedMap) Put(tx *types.Transaction) {
	nonce := tx.Nonce()
	if m.items[nonce] == nil {
		heap.Push(m.index, nonce)
	}
	m.items[nonce], m.cache = tx, nil
}
func (m *txSortedMap) Forward(threshold uint64) types.Transactions {
	var removed types.Transactions
	for m.index.Len() > 0 && (*m.index)[0] < threshold {
		nonce := heap.Pop(m.index).(uint64)
		removed = append(removed, m.items[nonce])
		delete(m.items, nonce)
	}
	if m.cache != nil {
		m.cache = m.cache[len(removed):]
	}
	return removed
}
func (m *txSortedMap) TryReplace(tx *types.Transaction) bool {
	if m.index.Len() <= 0 {
		return false
	}
	maxNonce := m.MaxNonce()
	if maxNonce <= tx.Nonce() {
		return false
	}
	m.Remove(maxNonce)
	if err := m.Add(tx); err != nil {
		return false
	}
	return true
}
func (m *txSortedMap) MaxNonce() uint64 {
	var sortedTxs types.Transactions
	if m.cache != nil {
		sortedTxs = m.cache
	} else {
		sortedTxs = m.Flatten()
	}
	maxNonce := (sortedTxs)[sortedTxs.Len()-1].Nonce()
	return maxNonce
}
func (m *txSortedMap) MinNonce() uint64 {
	var sortedTxs types.Transactions
	if m.cache != nil {
		sortedTxs = m.cache
	} else {
		sortedTxs = m.Flatten()
	}
	minNonce := (sortedTxs)[0].Nonce()
	return minNonce
}
func (m *txSortedMap) Remove(nonce uint64) bool {
	_, ok := m.items[nonce]
	if !ok {
		return false
	}
	for i := 0; i < m.index.Len(); i++ {
		if (*m.index)[i] == nonce {
			heap.Remove(m.index, i)
			break
		}
	}
	delete(m.items, nonce)
	m.cache = nil
	return true
}
func (m *txSortedMap) Ready(start uint64) types.Transactions {
	return m.ReadyN(start, m.Len())
}