// ReshufflePending reshuffles all transactions that may be proposed into a new block by recomputing
// the indices of all blocks given an updated block.
//
// It also prunes away transactions that are too stale, based on the index specified of the next
// block. It returns the total number of transactions pruned.
ReshufflePending reshuffles all transactions that may be proposed into a new block by recomputing
the indices of all blocks given an updated block.

It also prunes away transactions that are too stale, based on the index specified of the next
block. It returns the total number of transactions pruned.
// ReshufflePending reshuffles all transactions that may be proposed into a new block by recomputing // the indices of all blocks given an updated block . // // It also prunes away transactions that are too stale based on the index specified of the next // block . It returns the total number of transactions pruned .
func (t *Transactions) ReshufflePending(next Block) []TransactionID {
	t.Lock()
	defer t.Unlock()
	for _, id := range next.Transactions {
		t.finalized[id] = struct{}{}
	}
	var updated btree.BTree
	t.index.Scan(func(key []byte, value interface{}) bool {
		id := value.(TransactionID)
		if _, finalized := t.finalized[id]; finalized {
			return true
		}
		tx := t.buffer[id]
		if next.Index < tx.Block+uint64(conf.GetPruningLimit()) {
			updated.Set(tx.ComputeIndex(next.ID), id)
		}
		return true
	})
	t.index = updated
	var pruned []TransactionID
	for _, tx := range t.buffer {
		if next.Index >= tx.Block+uint64(conf.GetPruningLimit()) {
			delete(t.buffer, tx.ID)
			delete(t.finalized, tx.ID)
			pruned = append(pruned, tx.ID)
		}
	}
	for id, height := range t.missing {
		if next.Index >= height+uint64(conf.GetPruningLimit()) {
			delete(t.missing, id)
		}
	}
	t.latest = next
	return pruned
}
func ( t * Transactions ) ReshufflePending ( next Block ) [ ] TransactionID { t . Lock ( ) defer t . Unlock ( ) for _ , id := range next . Transactions { t . finalized [ id ] = struct { } { } } var updated btree . BTree t . index . Scan ( func ( key [ ] byte , value interface { } ) bool { id := value . ( TransactionID ) if _ , finalized := t . finalized [ id ] ; finalized { return true } tx := t . buffer [ id ] if next . Index < tx . Block + uint64 ( conf . GetPruningLimit ( ) ) { updated . Set ( tx . ComputeIndex ( next . ID ) , id ) } return true } ) t . index = updated var pruned [ ] TransactionID for _ , tx := range t . buffer { if next . Index >= tx . Block + uint64 ( conf . GetPruningLimit ( ) ) { delete ( t . buffer , tx . ID ) delete ( t . finalized , tx . ID ) pruned = append ( pruned , tx . ID ) } } for id , height := range t . missing { if next . Index >= height + uint64 ( conf . GetPruningLimit ( ) ) { delete ( t . missing , id ) } } t . latest = next return pruned }
ReshufflePending reshuffles all transactions that may be proposed into a new block by recomputing
the indices of all blocks given an updated block.
ReshufflePending reshuffles all transactions that may be proposed into a new block by recomputing the indices of all blocks given an updated block .
// Delete mempool entries for transactions in the finalized block. // Recompute indices of all items in the mempool. // Re-insert all mempool items with the recomputed indices. // Go through the entire transactions index and prune away // any transactions that are too old. // Prune any IDs of transactions that we are trying to pull from our peers // that have not managed to be pulled for `PruningLimit` blocks. // Have all IDs of transactions missing from now on be marked to be missing from // a new block height.