-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: replace unbuffered channels with buffered channels #1668
Changes from 11 commits
6885bae
797b0bf
0bbd004
c84976a
634050b
8ed5ee6
39eb00f
504e4f6
6395b5c
79db38b
c8936e5
3e43488
5cd262c
651e07a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ func TestStorageObserver_Update(t *testing.T) { | |
} | ||
|
||
func TestBlockListener_Listen(t *testing.T) { | ||
notifyChan := make(chan *types.Block) | ||
notifyChan := make(chan *types.Block, 100) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make the value There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added const DEFAULT_BUFFER_SIZE, and removed the buffers from the channels that are used in tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one could be unbuffered? |
||
mockConnection := &MockWSConnAPI{} | ||
bl := BlockListener{ | ||
Channel: notifyChan, | ||
|
@@ -95,7 +95,7 @@ func TestBlockListener_Listen(t *testing.T) { | |
} | ||
|
||
func TestBlockFinalizedListener_Listen(t *testing.T) { | ||
notifyChan := make(chan *types.FinalisationInfo) | ||
notifyChan := make(chan *types.FinalisationInfo, 100) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could be unbuffered? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated. |
||
mockConnection := &MockWSConnAPI{} | ||
bfl := BlockFinalizedListener{ | ||
channel: notifyChan, | ||
|
@@ -121,8 +121,8 @@ func TestBlockFinalizedListener_Listen(t *testing.T) { | |
} | ||
|
||
func TestExtrinsicSubmitListener_Listen(t *testing.T) { | ||
notifyImportedChan := make(chan *types.Block) | ||
notifyFinalizedChan := make(chan *types.FinalisationInfo) | ||
notifyImportedChan := make(chan *types.Block, 100) | ||
notifyFinalizedChan := make(chan *types.FinalisationInfo, 100) | ||
|
||
mockConnection := &MockWSConnAPI{} | ||
esl := ExtrinsicSubmitListener{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ import ( | |
"strings" | ||
"sync" | ||
|
||
"github.com/ChainSafe/gossamer/dot/core" | ||
"github.com/ChainSafe/gossamer/dot/rpc/modules" | ||
"github.com/ChainSafe/gossamer/dot/state" | ||
"github.com/ChainSafe/gossamer/dot/types" | ||
|
@@ -228,7 +229,7 @@ func (c *WSConn) unsubscribeStorageListener(reqID float64, l Listener, _ interfa | |
|
||
func (c *WSConn) initBlockListener(reqID float64, _ interface{}) (Listener, error) { | ||
bl := &BlockListener{ | ||
Channel: make(chan *types.Block), | ||
Channel: make(chan *types.Block, core.DEFAULT_BUFFER_SIZE), | ||
wsconn: c, | ||
} | ||
|
||
|
@@ -260,7 +261,7 @@ func (c *WSConn) initBlockListener(reqID float64, _ interface{}) (Listener, erro | |
|
||
func (c *WSConn) initBlockFinalizedListener(reqID float64, _ interface{}) (Listener, error) { | ||
bfl := &BlockFinalizedListener{ | ||
channel: make(chan *types.FinalisationInfo), | ||
channel: make(chan *types.FinalisationInfo, 100), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, updated. |
||
wsconn: c, | ||
} | ||
|
||
|
@@ -299,10 +300,10 @@ func (c *WSConn) initExtrinsicWatch(reqID float64, params interface{}) (Listener | |
|
||
// listen for built blocks | ||
esl := &ExtrinsicSubmitListener{ | ||
importedChan: make(chan *types.Block), | ||
importedChan: make(chan *types.Block, core.DEFAULT_BUFFER_SIZE), | ||
wsconn: c, | ||
extrinsic: types.Extrinsic(extBytes), | ||
finalisedChan: make(chan *types.FinalisationInfo), | ||
finalisedChan: make(chan *types.FinalisationInfo, 100), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated. |
||
} | ||
|
||
if c.BlockAPI == nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move this to
common
ordot/rpc/subscription
or such sincecore
isn't using it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to
dot/rpc/subscription