Skip to content

Commit

Permalink
Update server fields
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Oct 24, 2023
1 parent 0ba5291 commit 1e68170
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type Server struct {
allowLister authz.WalletAllowLister
authenticator *authn.XmtpAuthentication
grpc *api.Server
MLSStore *mlsstore.Store
mlsDB *bun.DB
}

// Create a new Server
Expand Down Expand Up @@ -229,20 +229,17 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error)
}
s.log.With(logging.MultiAddrs("listen", maddrs...)).Info("got server")

var MLSStore *mlsstore.Store
if options.MLSStore.DbConnectionString != "" {
s.log.Info("creating mls db")
mlsDb, err := createBunDB(options.MLSStore.DbConnectionString, options.WaitForDB, options.MLSStore.ReadTimeout, options.MLSStore.WriteTimeout, options.MLSStore.MaxOpenConns)
if err != nil {
if s.mlsDB, err = createBunDB(options.MLSStore.DbConnectionString, options.WaitForDB, options.MLSStore.ReadTimeout, options.MLSStore.WriteTimeout, options.MLSStore.MaxOpenConns); err != nil {
return nil, errors.Wrap(err, "creating mls db")
}

s.log.Info("creating mls store")
s.MLSStore, err = mlsstore.New(s.ctx, mlsstore.Config{
if MLSStore, err = mlsstore.New(s.ctx, mlsstore.Config{
Log: s.log,
DB: mlsDb,
})

if err != nil {
DB: s.mlsDB,
}); err != nil {
return nil, errors.Wrap(err, "creating mls store")
}
}
Expand All @@ -263,7 +260,7 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error)
Log: s.log.Named("`api"),
Waku: s.wakuNode,
Store: s.store,
MLSStore: s.MLSStore,
MLSStore: MLSStore,
AllowLister: s.allowLister,
MLSValidator: MLSValidator,
},
Expand Down Expand Up @@ -306,8 +303,8 @@ func (s *Server) Shutdown() {
if s.store != nil {
s.store.Close()
}
if s.MLSStore != nil {
s.MLSStore.Close()
if s.mlsDB != nil {
s.mlsDB.Close()
}

// Close metrics server.
Expand Down

0 comments on commit 1e68170

Please sign in to comment.