func (b *buffer) len() int {
	b.lock.RLock()
	defer b.lock.RUnlock()
	return len(b.data)
}
len return the current length of the buffer.
package hbbft
import (
	"math/rand"
	"sync"
	"time"
)
type buffer struct {
	lock sync.RWMutex
	data []Transaction
}
func newBuffer() *buffer {
	return &buffer{
		data: make([]Transaction, 0, 1024),
	}
}
func (b *buffer) push(tx Transaction) {
	b.lock.Lock()
	defer b.lock.Unlock()
	b.data = append(b.data, tx)
}
func (b *buffer) delete(txx []Transaction) {
	b.lock.Lock()
	defer b.lock.Unlock()
	temp := make(map[string]Transaction)
	for i := 0; i < len(b.data); i++ {
		temp[string(b.data[i].Hash())] = b.data[i]
	}
	for i := 0; i < len(txx); i++ {
		delete(temp, string(txx[i].Hash()))
	}
	data := make([]Transaction, len(temp))
	i := 0
	for _, tx := range temp {
		data[i] = tx
		i++
	}
	b.data = data
}