// GetQueuedTransactions returns all non-processable transactions. func (self *TxPool) GetQueuedTransactions() types.Transactions { self.mu.RLock() defer self.mu.RUnlock() var ret types.Transactions for _, txs := range self.queue { for _, tx := range txs { ret = append(ret, tx) } } sort.Sort(types.TxByNonce(ret)) return ret }
// Flatten creates a nonce-sorted slice of transactions based on the loosely // sorted internal representation. The result of the sorting is cached in case // it's requested again before any modifications are made to the contents. func (m *txSortedMap) Flatten() types.Transactions { // If the sorting was not cached yet, create and cache it if m.cache == nil { m.cache = make(types.Transactions, 0, len(m.items)) for _, tx := range m.items { m.cache = append(m.cache, tx) } sort.Sort(types.TxByNonce(m.cache)) } // Copy the cache to prevent accidental modifications txs := make(types.Transactions, len(m.cache)) copy(txs, m.cache) return txs }
// Pending returns all the transactions known to the pool func (p *testTxPool) Pending() map[common.Address]types.Transactions { p.lock.RLock() defer p.lock.RUnlock() batches := make(map[common.Address]types.Transactions) for _, tx := range p.pool { from, _ := tx.From() batches[from] = append(batches[from], tx) } for _, batch := range batches { sort.Sort(types.TxByNonce(batch)) } return batches }