Fix synchronization issue in mempool

This commit is contained in:
Martin Boehm 2019-04-11 14:57:39 +02:00
parent 8c1691be8d
commit 230b5e5d32

View File

@ -65,6 +65,7 @@ func (a MempoolTxidEntries) Less(i, j int) bool {
return hi > hj
}
// removeEntryFromMempool removes entry from mempool structs. The caller is responsible for locking!
func (m *BaseMempool) removeEntryFromMempool(txid string, entry txEntry) {
delete(m.txEntries, txid)
for _, si := range entry.addrIndexes {
@ -87,9 +88,9 @@ func (m *BaseMempool) removeEntryFromMempool(txid string, entry txEntry) {
// GetAllEntries returns all mempool entries sorted by fist seen time in descending order
func (m *BaseMempool) GetAllEntries() MempoolTxidEntries {
entries := make(MempoolTxidEntries, len(m.txEntries))
i := 0
m.mux.Lock()
entries := make(MempoolTxidEntries, len(m.txEntries))
for txid, entry := range m.txEntries {
entries[i] = MempoolTxidEntry{
Txid: txid,