node: cleanup buffer size configuration
This commit is contained in:
parent
44c8146c3f
commit
a1ce981b49
|
@ -62,6 +62,15 @@ import (
|
||||||
googleapi_option "google.golang.org/api/option"
|
googleapi_option "google.golang.org/api/option"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
inboundObservationBufferSize = 50
|
||||||
|
inboundSignedVaaBufferSize = 50
|
||||||
|
observationRequestOutboundBufferSize = 50
|
||||||
|
observationRequestInboundBufferSize = 50
|
||||||
|
// observationRequestBufferSize is the buffer size of the per-network reobservation channel
|
||||||
|
observationRequestBufferSize = 25
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
p2pNetworkID *string
|
p2pNetworkID *string
|
||||||
p2pPort *uint
|
p2pPort *uint
|
||||||
|
@ -403,9 +412,6 @@ var NodeCmd = &cobra.Command{
|
||||||
// guardians to reduce risk from a compromised builder.
|
// guardians to reduce risk from a compromised builder.
|
||||||
var Build = "prod"
|
var Build = "prod"
|
||||||
|
|
||||||
// observationRequestBufferSize is the buffer size of the per-network reobservation channel
|
|
||||||
const observationRequestBufferSize = 25
|
|
||||||
|
|
||||||
func runNode(cmd *cobra.Command, args []string) {
|
func runNode(cmd *cobra.Command, args []string) {
|
||||||
if Build == "dev" && !*unsafeDevMode {
|
if Build == "dev" && !*unsafeDevMode {
|
||||||
fmt.Println("This is a development build. --unsafeDevMode must be enabled.")
|
fmt.Println("This is a development build. --unsafeDevMode must be enabled.")
|
||||||
|
@ -907,13 +913,13 @@ func runNode(cmd *cobra.Command, args []string) {
|
||||||
setReadC, setWriteC := makeChannelPair[*common.GuardianSet](0)
|
setReadC, setWriteC := makeChannelPair[*common.GuardianSet](0)
|
||||||
|
|
||||||
// Inbound signed VAAs
|
// Inbound signed VAAs
|
||||||
signedInReadC, signedInWriteC := makeChannelPair[*gossipv1.SignedVAAWithQuorum](50)
|
signedInReadC, signedInWriteC := makeChannelPair[*gossipv1.SignedVAAWithQuorum](inboundSignedVaaBufferSize)
|
||||||
|
|
||||||
// Inbound observation requests from the p2p service (for all chains)
|
// Inbound observation requests from the p2p service (for all chains)
|
||||||
obsvReqReadC, obsvReqWriteC := makeChannelPair[*gossipv1.ObservationRequest](common.ObsvReqChannelSize)
|
obsvReqReadC, obsvReqWriteC := makeChannelPair[*gossipv1.ObservationRequest](observationRequestInboundBufferSize)
|
||||||
|
|
||||||
// Outbound observation requests
|
// Outbound observation requests
|
||||||
obsvReqSendReadC, obsvReqSendWriteC := makeChannelPair[*gossipv1.ObservationRequest](common.ObsvReqChannelSize)
|
obsvReqSendReadC, obsvReqSendWriteC := makeChannelPair[*gossipv1.ObservationRequest](observationRequestOutboundBufferSize)
|
||||||
|
|
||||||
// Injected VAAs (manually generated rather than created via observation)
|
// Injected VAAs (manually generated rather than created via observation)
|
||||||
injectReadC, injectWriteC := makeChannelPair[*vaa.VAA](0)
|
injectReadC, injectWriteC := makeChannelPair[*vaa.VAA](0)
|
||||||
|
|
|
@ -6,8 +6,6 @@ import (
|
||||||
gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
|
gossipv1 "github.com/certusone/wormhole/node/pkg/proto/gossip/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ObsvReqChannelSize = 50
|
|
||||||
|
|
||||||
var ErrChanFull = errors.New("channel is full")
|
var ErrChanFull = errors.New("channel is full")
|
||||||
|
|
||||||
func PostObservationRequest(obsvReqSendC chan<- *gossipv1.ObservationRequest, req *gossipv1.ObservationRequest) error {
|
func PostObservationRequest(obsvReqSendC chan<- *gossipv1.ObservationRequest, req *gossipv1.ObservationRequest) error {
|
||||||
|
|
|
@ -11,6 +11,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestObsvReqSendLimitEnforced(t *testing.T) {
|
func TestObsvReqSendLimitEnforced(t *testing.T) {
|
||||||
|
const ObsvReqChannelSize = 50
|
||||||
|
|
||||||
obsvReqSendC := make(chan *gossipv1.ObservationRequest, ObsvReqChannelSize)
|
obsvReqSendC := make(chan *gossipv1.ObservationRequest, ObsvReqChannelSize)
|
||||||
|
|
||||||
// If the channel overflows, the write hangs, so use a go routine with a timeout.
|
// If the channel overflows, the write hangs, so use a go routine with a timeout.
|
||||||
|
|
Loading…
Reference in New Issue