Skip to content

Commit

Permalink
cmd: use same data recorder for rhp2 and rhp3
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Dec 14, 2023
1 parent 13b09c1 commit 5e2f5b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 43 deletions.
27 changes: 0 additions & 27 deletions cmd/hostd/monitor.go

This file was deleted.

28 changes: 12 additions & 16 deletions cmd/hostd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,16 @@ type node struct {
registry *registry.Manager
storage *storage.VolumeManager

sessions *rhp.SessionReporter
rhp2Monitor *rhp.DataRecorder
rhp2 *rhp2.SessionHandler
rhp3Monitor *rhp.DataRecorder
rhp3 *rhp3.SessionHandler
sessions *rhp.SessionReporter
data *rhp.DataRecorder
rhp2 *rhp2.SessionHandler
rhp3 *rhp3.SessionHandler
}

func (n *node) Close() error {
n.rhp3.Close()
n.rhp2.Close()
n.rhp2Monitor.Close()
n.rhp3Monitor.Close()
n.data.Close()
n.storage.Close()
n.contracts.Close()
n.w.Close()
Expand Down Expand Up @@ -191,14 +189,13 @@ func newNode(walletKey types.PrivateKey, logger *zap.Logger) (*node, types.Priva

sessions := rhp.NewSessionReporter()

rhp2Monitor := rhp.NewDataRecorder(&rhp2MonitorStore{db}, logger.Named("rhp2Monitor"))
rhp2, err := startRHP2(rhp2Listener, hostKey, rhp3Listener.Addr().String(), cm, tp, w, contractManager, sr, sm, rhp2Monitor, sessions, logger.Named("rhp2"))
dm := rhp.NewDataRecorder(db, logger.Named("data"))
rhp2, err := startRHP2(rhp2Listener, hostKey, rhp3Listener.Addr().String(), cm, tp, w, contractManager, sr, sm, dm, sessions, logger.Named("rhp2"))
if err != nil {
return nil, types.PrivateKey{}, fmt.Errorf("failed to start rhp2: %w", err)
}

rhp3Monitor := rhp.NewDataRecorder(&rhp3MonitorStore{db}, logger.Named("rhp3Monitor"))
rhp3, err := startRHP3(rhp3Listener, hostKey, cm, tp, w, accountManager, contractManager, registryManager, sr, sm, rhp3Monitor, sessions, logger.Named("rhp3"))
rhp3, err := startRHP3(rhp3Listener, hostKey, cm, tp, w, accountManager, contractManager, registryManager, sr, sm, dm, sessions, logger.Named("rhp3"))
if err != nil {
return nil, types.PrivateKey{}, fmt.Errorf("failed to start rhp3: %w", err)
}
Expand All @@ -219,10 +216,9 @@ func newNode(walletKey types.PrivateKey, logger *zap.Logger) (*node, types.Priva
storage: sm,
registry: registryManager,

sessions: sessions,
rhp2Monitor: rhp2Monitor,
rhp2: rhp2,
rhp3Monitor: rhp3Monitor,
rhp3: rhp3,
sessions: sessions,
data: dm,
rhp2: rhp2,
rhp3: rhp3,
}, hostKey, nil
}

0 comments on commit 5e2f5b6

Please sign in to comment.