func (m *mruNonceMap) Delete(nonce uint64) {
	m.mtx.Lock()
	if node, exists := m.nonceMap[nonce]; exists {
		m.nonceList.Remove(node)
		delete(m.nonceMap, nonce)
	}
	m.mtx.Unlock()
}
Delete deletes the passed nonce from the map (if it exists).

This function is safe for concurrent access.
package peer
import (
	"bytes"
	"container/list"
	"fmt"
	"sync"
)
type mruNonceMap struct {
	mtx       sync.Mutex
	nonceMap  map[uint64]*list.Element  
	nonceList *list.List                
	limit     uint
}
func (m *mruNonceMap) String() string {
	m.mtx.Lock()
	defer m.mtx.Unlock()
	lastEntryNum := len(m.nonceMap) - 1
	curEntry := 0
	buf := bytes.NewBufferString("[")
	for nonce := range m.nonceMap {
		buf.WriteString(fmt.Sprintf("%d", nonce))
		if curEntry < lastEntryNum {
			buf.WriteString(", ")
		}
		curEntry++
	}
	buf.WriteString("]")
	return fmt.Sprintf("<%d>%s", m.limit, buf.String())
}
func (m *mruNonceMap) Exists(nonce uint64) bool {
	m.mtx.Lock()
	_, exists := m.nonceMap[nonce]
	m.mtx.Unlock()
	return exists
}
func (m *mruNonceMap) Add(nonce uint64) {
	m.mtx.Lock()
	defer m.mtx.Unlock()
	if m.limit == 0 {
		return
	}
	if node, exists := m.nonceMap[nonce]; exists {
		m.nonceList.MoveToFront(node)
		return
	}
	if uint(len(m.nonceMap))+1 > m.limit {
		node := m.nonceList.Back()
		lru := node.Value.(uint64)
		delete(m.nonceMap, lru)
		node.Value = nonce
		m.nonceList.MoveToFront(node)
		m.nonceMap[nonce] = node
		return
	}
	node := m.nonceList.PushFront(nonce)
	m.nonceMap[nonce] = node
}