Skip to content

Commit

Permalink
Made pendingHeaderCh buffered on the pendingHeaderFeed subscription
Browse files Browse the repository at this point in the history
This has improved the test performance, and more tolerant to small miner stalls
  • Loading branch information
gameofpointers committed Aug 21, 2023
1 parent d936741 commit d375f3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import (
"github.com/dominant-strategies/go-quai/rpc"
)

const (
c_pendingHeaderChSize = 20
)

// filter is a helper struct that holds meta information over the filter type
// and associated subscription in the event system.
type filter struct {
Expand Down Expand Up @@ -594,7 +598,7 @@ func (api *PublicFilterAPI) PendingHeader(ctx context.Context) (*rpc.Subscriptio
rpcSub := notifier.CreateSubscription()

go func() {
header := make(chan *types.Header)
header := make(chan *types.Header, c_pendingHeaderChSize)
headerSub := api.events.SubscribePendingHeader(header)

for {
Expand Down
4 changes: 3 additions & 1 deletion eth/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const (
logsChanSize = 10
// chainEvChanSize is the size of channel listening to ChainEvent.
chainEvChanSize = 10
// pendingHeaderChSize is the size of channel listening to PendingHeaderEvent.
pendingHeaderChSize = 20
)

type subscription struct {
Expand Down Expand Up @@ -126,7 +128,7 @@ func NewEventSystem(backend Backend, lightMode bool) *EventSystem {
rmLogsCh: make(chan core.RemovedLogsEvent, rmLogsChanSize),
pendingLogsCh: make(chan []*types.Log, logsChanSize),
chainCh: make(chan core.ChainEvent, chainEvChanSize),
pendingHeaderCh: make(chan *types.Header),
pendingHeaderCh: make(chan *types.Header, pendingHeaderChSize),
}

nodeCtx := common.NodeLocation.Context()
Expand Down

0 comments on commit d375f3b

Please sign in to comment.