func (wtl *WrappedTxList) Insert(wtx *WrappedTx) {
	wtl.mtx.Lock()
	defer wtl.mtx.Unlock()
	i := sort.Search(len(wtl.txs), func(i int) bool {
		return wtl.less(wtl.txs[i], wtx)
	})
	if i == len(wtl.txs) {
		wtl.txs = append(wtl.txs, wtx)
		return
	}
	wtl.txs = append(wtl.txs[:i+1], wtl.txs[i:]...)
	wtl.txs[i] = wtx
}
Insert inserts a WrappedTx reference into the sorted list based on the list's
comparator function.
package v1
import (
	"sort"
	"time"
	"github.com/tendermint/tendermint/internal/libs/clist"
	tmsync "github.com/tendermint/tendermint/internal/libs/sync"
	"github.com/tendermint/tendermint/types"
)
type WrappedTx struct {
	tx types.Tx
	hash types.TxKey
	height int64
	gasWanted int64
	priority int64
	sender string
	timestamp time.Time
	peers map[uint16]struct{}
	heapIndex int
	gossipEl *clist.CElement
	removed bool
}
func (wtx *WrappedTx) Size() int {
	return len(wtx.tx)
}
type TxStore struct {
	mtx       tmsync.RWMutex
	hashTxs   map[types.TxKey]*WrappedTx  
	senderTxs map[string]*WrappedTx       
}
func NewTxStore() *TxStore {
	return &TxStore{
		senderTxs: make(map[string]*WrappedTx),
		hashTxs:   make(map[types.TxKey]*WrappedTx),
	}
}
func (txs *TxStore) Size() int {
	txs.mtx.RLock()
	defer txs.mtx.RUnlock()
	return len(txs.hashTxs)
}
func (txs *TxStore) GetAllTxs() []*WrappedTx {
	txs.mtx.RLock()
	defer txs.mtx.RUnlock()
	wTxs := make([]*WrappedTx, len(txs.hashTxs))
	i := 0
	for _, wtx := range txs.hashTxs {
		wTxs[i] = wtx
		i++
	}
	return wTxs
}
func (txs *TxStore) GetTxBySender(sender string) *WrappedTx {
	txs.mtx.RLock()
	defer txs.mtx.RUnlock()
	return txs.senderTxs[sender]
}
func (txs *TxStore) GetTxByHash(hash types.TxKey) *WrappedTx {
	txs.mtx.RLock()
	defer txs.mtx.RUnlock()
	return txs.hashTxs[hash]
}
func (txs *TxStore) IsTxRemoved(hash types.TxKey) bool {
	txs.mtx.RLock()
	defer txs.mtx.RUnlock()
	wtx, ok := txs.hashTxs[hash]
	if ok {
		return wtx.removed
	}
	return false
}
func (txs *TxStore) SetTx(wtx *WrappedTx) {
	txs.mtx.Lock()
	defer txs.mtx.Unlock()
	if len(wtx.sender) > 0 {
		txs.senderTxs[wtx.sender] = wtx
	}
	txs.hashTxs[wtx.tx.Key()] = wtx
}
func (txs *TxStore) RemoveTx(wtx *WrappedTx) {
	txs.mtx.Lock()
	defer txs.mtx.Unlock()
	if len(wtx.sender) > 0 {
		delete(txs.senderTxs, wtx.sender)
	}
	delete(txs.hashTxs, wtx.tx.Key())
	wtx.removed = true
}
func (txs *TxStore) TxHasPeer(hash types.TxKey, peerID uint16) bool {
	txs.mtx.RLock()
	defer txs.mtx.RUnlock()
	wtx := txs.hashTxs[hash]
	if wtx == nil {
		return false
	}
	_, ok := wtx.peers[peerID]
	return ok
}
func (txs *TxStore) GetOrSetPeerByTxHash(hash types.TxKey, peerID uint16) (*WrappedTx, bool) {
	txs.mtx.Lock()
	defer txs.mtx.Unlock()
	wtx := txs.hashTxs[hash]
	if wtx == nil {
		return nil, false
	}
	if wtx.peers == nil {
		wtx.peers = make(map[uint16]struct{})
	}
	if _, ok := wtx.peers[peerID]; ok {
		return wtx, true
	}
	wtx.peers[peerID] = struct{}{}
	return wtx, false
}
type WrappedTxList struct {
	mtx  tmsync.RWMutex
	txs  []*WrappedTx
	less func(*WrappedTx, *WrappedTx) bool
}
func NewWrappedTxList(less func(*WrappedTx, *WrappedTx) bool) *WrappedTxList {
	return &WrappedTxList{
		txs:  make([]*WrappedTx, 0),
		less: less,
	}
}
func (wtl *WrappedTxList) Size() int {
	wtl.mtx.RLock()
	defer wtl.mtx.RUnlock()
	return len(wtl.txs)
}
func (wtl *WrappedTxList) Reset() {
	wtl.mtx.Lock()
	defer wtl.mtx.Unlock()
	wtl.txs = make([]*WrappedTx, 0)
}