Skip to content

Commit

Permalink
replaces network startup
Browse files Browse the repository at this point in the history
  • Loading branch information
yhassanzadeh13 committed May 20, 2021
1 parent 9559281 commit e6a748e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions engine/verification/requester/requester.go
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/opentracing/opentracing-go"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"golang.org/x/exp/rand"

"github.com/onflow/flow-go/engine"
Expand Down Expand Up @@ -48,6 +49,7 @@ type Engine struct {
unit *engine.Unit
state protocol.State // used to check the last sealed height.
con network.Conduit // used to send the chunk data request, and receive the response.
net module.Network

// monitoring
tracer module.Tracer
Expand Down Expand Up @@ -86,14 +88,9 @@ func New(log zerolog.Logger,
pendingRequests: pendingRequests,
reqUpdaterFunc: reqUpdaterFunc,
reqQualifierFunc: reqQualifierFunc,
net: net,
}

con, err := net.Register(engine.RequestChunks, e)
if err != nil {
return nil, fmt.Errorf("could not register chunk data pack provider engine: %w", err)
}
e.con = con

return e, nil
}

Expand Down Expand Up @@ -134,10 +131,19 @@ func (e *Engine) Process(originID flow.Identifier, event interface{}) error {
// Ready initializes the engine and returns a channel that is closed when the initialization is done.
func (e *Engine) Ready() <-chan struct{} {
if e.handler == nil {
// we should crash the node with fatal-level log if handler is missing
e.log.Fatal().Msg("could not start requester engine with missing chunk data pack handler")
}

con, err := e.net.Register(engine.RequestChunks, e)
if err != nil {
// we should crash the node with fatal-level log if network module is missing
log.Fatal().Err(err).Msg("could not register requester engine on network")
}
e.con = con

delay := time.Duration(0)

// run a periodic check to retry requesting chunk data packs.
// if onTimer takes longer than retryInterval, the next call will be blocked until the previous
// call has finished.
Expand Down

0 comments on commit e6a748e

Please sign in to comment.