Skip to content

Commit dcd97c4

Browse files
nonsensekaralabe
authored andcommitted
swarm, swarm/network, swarm/pss: log error and fix logs (#17410)
* swarm, swarm/network, swarm/pss: log error and fix logs * swarm/pss: log compressed publickey
1 parent 85c6a1c commit dcd97c4

3 files changed

Lines changed: 21 additions & 22 deletions

File tree

‎swarm/network/hive.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ func NewHive(params *HiveParams, overlay Overlay, store state.Store) *Hive {
102102
// server is used to connect to a peer based on its NodeID or enode URL
103103
// these are called on the p2p.Server which runs on the node
104104
func (h *Hive) Start(server *p2p.Server) error {
105-
log.Info(fmt.Sprintf("%08x hive starting", h.BaseAddr()[:4]))
105+
log.Info("Starting hive", "baseaddr", fmt.Sprintf("%x", h.BaseAddr()[:4]))
106106
// if state store is specified, load peers to prepopulate the overlay address book
107107
if h.Store != nil {
108-
log.Info("detected an existing store. trying to load peers")
108+
log.Info("Detected an existing store. trying to load peers")
109109
if err := h.loadPeers(); err != nil {
110110
log.Error(fmt.Sprintf("%08x hive encoutered an error trying to load peers", h.BaseAddr()[:4]))
111111
return err

‎swarm/pss/pss.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,13 @@ func (p *Pss) Start(srv *p2p.Server) error {
232232
}
233233
}
234234
}()
235-
log.Debug("Started pss", "public key", common.ToHex(crypto.FromECDSAPub(p.PublicKey())))
235+
log.Info("Started Pss")
236+
log.Info("Loaded EC keys", "pubkey", common.ToHex(crypto.FromECDSAPub(p.PublicKey())), "secp256", common.ToHex(crypto.CompressPubkey(p.PublicKey())))
236237
return nil
237238
}
238239

239240
func (p *Pss) Stop() error {
240-
log.Info("pss shutting down")
241+
log.Info("Pss shutting down")
241242
close(p.quitC)
242243
return nil
243244
}

‎swarm/swarm.go‎

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,10 @@ func NewSwarm(config *api.Config, mockStore *mock.NodeStore) (self *Swarm, err e
121121
backend: backend,
122122
privateKey: config.ShiftPrivateKey(),
123123
}
124-
log.Debug(fmt.Sprintf("Setting up Swarm service components"))
124+
log.Debug("Setting up Swarm service components")
125125

126126
config.HiveParams.Discovery = true
127127

128-
log.Debug(fmt.Sprintf("-> swarm net store shared access layer to Swarm Chunk Store"))
129-
130128
nodeID, err := discover.HexID(config.NodeID)
131129
if err != nil {
132130
return nil, err
@@ -201,8 +199,7 @@ func NewSwarm(config *api.Config, mockStore *mock.NodeStore) (self *Swarm, err e
201199
resourceHandler,
202200
}
203201

204-
// setup local store
205-
log.Debug(fmt.Sprintf("Set up local storage"))
202+
log.Debug("Setup local storage")
206203

207204
self.bzz = network.NewBzz(bzzconfig, to, stateStore, stream.Spec, self.streamer.Run)
208205

@@ -216,11 +213,9 @@ func NewSwarm(config *api.Config, mockStore *mock.NodeStore) (self *Swarm, err e
216213
}
217214

218215
self.api = api.NewAPI(self.fileStore, self.dns, resourceHandler, self.privateKey)
219-
// Manifests for Smart Hosting
220-
log.Debug(fmt.Sprintf("-> Web3 virtual server API"))
221216

222217
self.sfs = fuse.NewSwarmFS(self.api)
223-
log.Debug("-> Initializing Fuse file system")
218+
log.Debug("Initialized FUSE filesystem")
224219

225220
return self, nil
226221
}
@@ -341,7 +336,7 @@ func (self *Swarm) Start(srv *p2p.Server) error {
341336

342337
// update uaddr to correct enode
343338
newaddr := self.bzz.UpdateLocalAddr([]byte(srv.Self().String()))
344-
log.Warn("Updated bzz local addr", "oaddr", fmt.Sprintf("%x", newaddr.OAddr), "uaddr", fmt.Sprintf("%s", newaddr.UAddr))
339+
log.Info("Updated bzz local addr", "oaddr", fmt.Sprintf("%x", newaddr.OAddr), "uaddr", fmt.Sprintf("%s", newaddr.UAddr))
345340
// set chequebook
346341
if self.config.SwapEnabled {
347342
ctx := context.Background() // The initial setup has no deadline.
@@ -354,32 +349,35 @@ func (self *Swarm) Start(srv *p2p.Server) error {
354349
log.Debug(fmt.Sprintf("SWAP disabled: no cheque book set"))
355350
}
356351

357-
log.Warn(fmt.Sprintf("Starting Swarm service"))
352+
log.Info("Starting bzz service")
358353

359354
err := self.bzz.Start(srv)
360355
if err != nil {
361356
log.Error("bzz failed", "err", err)
362357
return err
363358
}
364-
log.Info(fmt.Sprintf("Swarm network started on bzz address: %x", self.bzz.Hive.Overlay.BaseAddr()))
359+
log.Info("Swarm network started", "bzzaddr", fmt.Sprintf("%x", self.bzz.Hive.Overlay.BaseAddr()))
365360

366361
if self.ps != nil {
367362
self.ps.Start(srv)
368-
log.Info("Pss started")
369363
}
370364

371365
// start swarm http proxy server
372366
if self.config.Port != "" {
373367
addr := net.JoinHostPort(self.config.ListenAddr, self.config.Port)
374368
server := httpapi.NewServer(self.api, self.config.Cors)
375369

376-
go server.ListenAndServe(addr)
377-
}
378-
379-
log.Debug(fmt.Sprintf("Swarm http proxy started on port: %v", self.config.Port))
370+
if self.config.Cors != "" {
371+
log.Debug("Swarm HTTP proxy CORS headers", "allowedOrigins", self.config.Cors)
372+
}
380373

381-
if self.config.Cors != "" {
382-
log.Debug(fmt.Sprintf("Swarm http proxy started with corsdomain: %v", self.config.Cors))
374+
log.Debug("Starting Swarm HTTP proxy", "port", self.config.Port)
375+
go func() {
376+
err := server.ListenAndServe(addr)
377+
if err != nil {
378+
log.Error("Could not start Swarm HTTP proxy", "err", err.Error())
379+
}
380+
}()
383381
}
384382

385383
self.periodicallyUpdateGauges()

0 commit comments

Comments
 (0)