network: change server Start() behavior

Previously user should Start server in a separate goroutine. Now
separate goroutine is created inside the Start(). For normal server
operation, the caller should wait for Start to finish. Also, fixed
TestTryInitStateSync test which was exiting earlier than logs are
called.

Close #3112

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
Ekaterina Pavlova 2024-02-21 18:07:28 +03:00
parent 224808975b
commit f8dc5ec44f
5 changed files with 10 additions and 10 deletions

View file

@ -262,7 +262,7 @@ func (s *Server) ID() uint32 {
}
// Start will start the server and its underlying transport. Calling it twice
// is an error.
// is an error. Caller should wait for Start to finish for normal server operation.
func (s *Server) Start() {
s.log.Info("node started",
zap.Uint32("blockHeight", s.chain.BlockHeight()),
@ -285,7 +285,7 @@ func (s *Server) Start() {
setServerAndNodeVersions(s.UserAgent, strconv.FormatUint(uint64(s.id), 10))
setNeoGoVersion(config.Version)
setSeverID(strconv.FormatUint(uint64(s.id), 10))
s.run()
go s.run()
}
// Shutdown disconnects all peers and stops listening. Calling it twice is an error,