mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Cycle the BLS changes pool when falling below a threshold (#11873)
* Cycle the BLS changes pool when falling below a threshold * move cycle logic within pool * set threshold at 2000 * fix conflict * more fixes --------- Co-authored-by: kasey <489222+kasey@users.noreply.github.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -24,6 +24,21 @@ type Node[T any] struct {
|
||||
next *Node[T]
|
||||
}
|
||||
|
||||
// Copy returns a copy of the origina list.
|
||||
func (l *List[T]) Copy() *List[T] {
|
||||
if l == nil {
|
||||
return nil
|
||||
}
|
||||
list := &List[T]{}
|
||||
if l.len == 0 {
|
||||
return list
|
||||
}
|
||||
for n := l.First(); n != nil; n = n.next {
|
||||
list.Append(n.Copy())
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
// First gets the reference to the first node in the list.
|
||||
func (l *List[T]) First() *Node[T] {
|
||||
return l.first
|
||||
@@ -111,3 +126,12 @@ func (n *Node[T]) Value() (T, error) {
|
||||
}
|
||||
return n.value, nil
|
||||
}
|
||||
|
||||
// Copy copies the given node and returns a new one. It does not do a deep copy
|
||||
// of T.
|
||||
func (n *Node[T]) Copy() *Node[T] {
|
||||
if n == nil {
|
||||
return nil
|
||||
}
|
||||
return NewNode(n.value)
|
||||
}
|
||||
|
||||
@@ -123,3 +123,36 @@ func TestRemove(t *testing.T) {
|
||||
require.Equal(t, 2, list.len)
|
||||
})
|
||||
}
|
||||
|
||||
func TestNodeCopy(t *testing.T) {
|
||||
first := NewNode(1)
|
||||
second := first.Copy()
|
||||
v, err := second.Value()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, first.value, v)
|
||||
}
|
||||
|
||||
func TestListCopy(t *testing.T) {
|
||||
list := &List[int]{}
|
||||
first := NewNode(1)
|
||||
second := NewNode(2)
|
||||
third := NewNode(3)
|
||||
list.Append(first)
|
||||
list.Append(second)
|
||||
list.Append(third)
|
||||
|
||||
copied := list.Copy()
|
||||
require.Equal(t, 3, copied.Len())
|
||||
m := copied.First()
|
||||
for n := list.First(); n != nil; n = n.next {
|
||||
nv, err := n.Value()
|
||||
require.NoError(t, err)
|
||||
mv, err := m.Value()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, nv, mv)
|
||||
|
||||
require.NotEqual(t, n, m)
|
||||
m, err = m.Next()
|
||||
require.NoError(t, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user