SMP protocol: optimize batching transactions, remove Builder (#961)

* remove Builder

* fewer chunks

* remove lazy bytestrings

* optimize

* pad
This commit is contained in:
Evgeny Poberezkin
2024-01-14 20:42:47 +00:00
committed by GitHub
parent cd4329f2de
commit 7f7a77c4eb
17 changed files with 64 additions and 149 deletions

View File

@@ -11,7 +11,6 @@ module Simplex.Messaging.Encoding
( Encoding (..),
Tail (..),
Large (..),
encodeLarge,
_smpP,
smpEncodeList,
smpListP,
@@ -30,8 +29,6 @@ import qualified Data.List.NonEmpty as L
import Data.Time.Clock.System (SystemTime (..))
import Data.Word (Word16, Word32)
import Network.Transport.Internal (decodeWord16, decodeWord32, encodeWord16, encodeWord32)
import Simplex.Messaging.Builder (Builder, word16BE)
import qualified Simplex.Messaging.Builder as BB
import Simplex.Messaging.Parsers (parseAll)
import Simplex.Messaging.Util ((<$?>))
@@ -141,10 +138,6 @@ instance Encoding Large where
Large <$> A.take len
{-# INLINE smpP #-}
encodeLarge :: Builder -> Builder
encodeLarge s = word16BE (fromIntegral $ BB.length s) <> s
{-# INLINE encodeLarge #-}
instance Encoding SystemTime where
smpEncode = smpEncode . systemSeconds
{-# INLINE smpEncode #-}