mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-10-22 19:42:34 +00:00
SMP protocol: optimize batching transactions, remove Builder (#961)
* remove Builder * fewer chunks * remove lazy bytestrings * optimize * pad
This commit is contained in:
1 parent
cd4329f2de
commit
7f7a77c4eb
17 files changed
+64
-149
No files matched your search
@@ -140,7 +140,6 @@ module Simplex.Messaging.Crypto
|
||||
|
||||
-- * Message padding / un-padding
|
||||
pad,
|
||||
pad',
|
||||
unPad,
|
||||
|
||||
-- * X509 Certificates
|
||||
@@ -206,8 +205,6 @@ import Database.SQLite.Simple.FromField (FromField (..))
|
||||
import Database.SQLite.Simple.ToField (ToField (..))
|
||||
import GHC.TypeLits (ErrorMessage (..), KnownNat, Nat, TypeError, natVal, type (+))
|
||||
import Network.Transport.Internal (decodeWord16, encodeWord16)
|
||||
import Simplex.Messaging.Builder (Builder, byteString, word16BE)
|
||||
import qualified Simplex.Messaging.Builder as BB
|
||||
import Simplex.Messaging.Encoding
|
||||
import Simplex.Messaging.Encoding.String
|
||||
import Simplex.Messaging.Parsers (blobFieldDecoder, parseAll, parseString)
|
||||
@@ -922,14 +919,6 @@ pad msg paddedLen
|
||||
len = B.length msg
|
||||
padLen = paddedLen - len - 2
|
||||
|
||||
pad' :: Builder -> Int -> Either CryptoError Builder
|
||||
pad' msg paddedLen
|
||||
| len <= maxMsgLen && padLen >= 0 = Right $ word16BE (fromIntegral len) <> msg <> byteString (B.replicate padLen '#')
|
||||
| otherwise = Left CryptoLargeMsgError
|
||||
where
|
||||
len = BB.length msg
|
||||
padLen = paddedLen - len - 2
|
||||
|
||||
unPad :: ByteString -> Either CryptoError ByteString
|
||||
unPad padded
|
||||
| B.length lenWrd == 2 && B.length rest >= len = Right $ B.take len rest
|
||||
|
||||
Reference in new issue
Block a user