66{-# LANGUAGE DerivingStrategies #-}
77{-# LANGUAGE FlexibleContexts #-}
88{-# LANGUAGE FlexibleInstances #-}
9+ {-# LANGUAGE ImportQualifiedPost #-}
910{-# LANGUAGE LambdaCase #-}
1011{-# LANGUAGE MultiWayIf #-}
1112{-# LANGUAGE NumericUnderscores #-}
@@ -45,40 +46,6 @@ module Main
4546, main
4647) where
4748
48- import Configuration.Utils hiding (Error )
49- import Configuration.Utils.Validation (validateFilePath )
50-
51- import Control.Concurrent
52- import Control.Concurrent.Async
53- import Control.DeepSeq
54- import Control.Exception
55- import Control.Lens hiding ((.=) )
56- import Control.Monad
57- import Control.Monad.Managed
58-
59- import Data.Text (Text )
60- import qualified Data.Text as T
61- import Data.Time
62- import Data.Typeable
63-
64- import GHC.Generics hiding (from )
65- import GHC.Stack
66- import GHC.Stats
67-
68- import qualified Network.HTTP.Client as HTTP
69- import qualified Network.HTTP.Client.TLS as HTTPS
70-
71- import qualified Streaming.Prelude as S
72-
73- import System.Directory
74- import System.FilePath
75- import System.IO
76- import qualified System.Logger as L
77- import System.LogLevel
78- import System.Mem
79-
80- -- internal modules
81-
8249import Chainweb.BlockHeader
8350import Chainweb.Chainweb
8451import Chainweb.Chainweb.Configuration
@@ -94,35 +61,50 @@ import Chainweb.Mempool.Consensus (ReintroducedTxsLog)
9461import Chainweb.Mempool.InMemTypes (MempoolStats (.. ))
9562import Chainweb.Miner.Coordinator (MiningStats )
9663import Chainweb.Pact.Backend.DbCache (DbCacheStats )
97- import Chainweb.Pact.Service.PactQueue (PactQueueStats )
9864import Chainweb.Pact.RestAPI.Server (PactCmdLog (.. ))
65+ import Chainweb.Pact.Service.PactQueue (PactQueueStats )
9966import Chainweb.Pact.Types
10067import Chainweb.Payload
10168import Chainweb.Payload.PayloadStore
69+ import Chainweb.Storage.Table.RocksDB
10270import Chainweb.Time
103- import Data.Time.Format.ISO8601
10471import Chainweb.Utils
10572import Chainweb.Utils.RequestLog
10673import Chainweb.Version
10774import Chainweb.Version.Mainnet
108- import Chainweb.Version.Testnet04 (testnet04 )
10975import Chainweb.Version.Registry
110-
111- import Chainweb.Storage.Table.RocksDB
112-
76+ import Configuration.Utils hiding (Error )
77+ import Configuration.Utils.Validation (validateFilePath )
78+ import Control.Concurrent
79+ import Control.Concurrent.Async
80+ import Control.DeepSeq
81+ import Control.Exception
82+ import Control.Lens hiding ((.=) )
83+ import Control.Monad
84+ import Control.Monad.Managed
11385import Data.LogMessage
114-
86+ import Data.Text (Text )
87+ import Data.Typeable
88+ import GHC.Generics hiding (from )
89+ import GHC.Stack
90+ import GHC.Stats
91+ import Network.HTTP.Client qualified as HTTP
92+ import Network.HTTP.Client.TLS qualified as HTTPS
11593import P2P.Node
116-
11794import PkgInfo
118-
95+ import Streaming.Prelude qualified as S
96+ import System.Directory
97+ import System.FilePath
98+ import System.IO
99+ import System.LogLevel
100+ import System.Logger qualified as L
101+ import System.Mem
102+ import Utils.CheckRLimits
103+ import Utils.InstallSignalHandlers
119104import Utils.Logging
120105import Utils.Logging.Config
121106import Utils.Logging.Trace
122107
123- import Utils.CheckRLimits
124- import Utils.InstallSignalHandlers
125-
126108-- -------------------------------------------------------------------------- --
127109-- Configuration
128110
@@ -479,60 +461,6 @@ mkTelemetryLogger
479461mkTelemetryLogger mgr = configureHandler
480462 $ withJsonHandleBackend @ a (sshow $ typeRep $ Proxy @ a ) mgr pkgInfoScopes
481463
482- -- -------------------------------------------------------------------------- --
483- -- Service Date
484-
485- newtype ServiceDate = ServiceDate Text
486-
487- instance Show ServiceDate where
488- show (ServiceDate t) = " Service interval end: " <> T. unpack t
489-
490- instance Exception ServiceDate where
491- fromException = asyncExceptionFromException
492- toException = asyncExceptionToException
493-
494- withServiceDate
495- :: ChainwebVersion
496- -> (LogLevel -> Text -> IO () )
497- -> Maybe UTCTime
498- -> IO a
499- -> IO a
500- withServiceDate v lf msd inner = case msd of
501- Nothing -> do
502- inner
503- Just sd -> do
504- if _versionCode v == _versionCode mainnet || _versionCode v == _versionCode testnet04
505- then do
506- race (timer sd) inner >>= \ case
507- Left () -> error " Service date thread terminated unexpectedly"
508- Right a -> return a
509- else do
510- inner
511- where
512- timer t = runForever lf " ServiceDate" $ do
513- now <- getCurrentTime
514- when (now >= t) $ do
515- lf Error shutdownMessage
516- throw $ ServiceDate shutdownMessage
517-
518- let w = diffUTCTime t now
519- let micros = round $ w * 1_000_000
520- lf Warn warning
521- threadDelay $ min (10 * 60 * 1_000_000 ) micros
522-
523- where
524- warning :: Text
525- warning = T. concat
526- [ " This version of chainweb node will stop working at " <> sshow t <> " ."
527- , " Please upgrade to a new version before that date."
528- ]
529-
530- shutdownMessage :: Text
531- shutdownMessage = T. concat
532- [ " Shutting down. This version of chainweb was only valid until " <> sshow t <> " ."
533- , " Please upgrade to a new version."
534- ]
535-
536464-- -------------------------------------------------------------------------- --
537465-- Encode Package Info into Log mesage scopes
538466
@@ -575,9 +503,7 @@ main = do
575503 , Handler $ \ (e :: SomeException ) ->
576504 logFunctionJson logger Error (ProcessDied $ show e) >> throwIO e
577505 ] $ do
578- kt <- mapM iso8601ParseM (_versionServiceDate v)
579- withServiceDate (_configChainwebVersion (_nodeConfigChainweb conf)) (logFunctionText logger) kt $ void $
580- race (node conf logger) (gcRunner (logFunctionText logger))
506+ void $ race (node conf logger) (gcRunner (logFunctionText logger))
581507 where
582508 gcRunner lf = runForever lf " GarbageCollect" $ do
583509 performMajorGC
0 commit comments