aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rawblock.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/rawblock.nim b/src/rawblock.nim
index e45c83f..0a44550 100644
--- a/src/rawblock.nim
+++ b/src/rawblock.nim
@@ -16,7 +16,7 @@
16 16
17import integers, bitreader, bitwriter 17import integers, bitreader, bitwriter
18 18
19const maxDataBitLength = 100_000_000 * wordBitLength # 100MB 19const maxDataBitLength = high(uint16).int - 1
20const bitLengthFieldBitLength = 2 * wordBitLength 20const bitLengthFieldBitLength = 2 * wordBitLength
21 21
22type RawBlock* = object 22type RawBlock* = object
@@ -25,7 +25,7 @@ type RawBlock* = object
25 25
26proc readSerialised*(bitReader: BitReader): RawBlock = 26proc readSerialised*(bitReader: BitReader): RawBlock =
27 let bitLength = bitReader.readBits(bitLengthFieldBitLength, uint16).int 27 let bitLength = bitReader.readBits(bitLengthFieldBitLength, uint16).int
28 let data = readSeq(bitReader, bitLength, uint8) 28 let data = bitReader.readSeq(bitLength, uint8)
29 RawBlock(bitLength: bitLength, data: data.data) 29 RawBlock(bitLength: bitLength, data: data.data)
30 30
31proc writeSerialisedTo*(rawBlock: RawBlock, bitWriter: BitWriter) = 31proc writeSerialisedTo*(rawBlock: RawBlock, bitWriter: BitWriter) =
@@ -33,7 +33,7 @@ proc writeSerialisedTo*(rawBlock: RawBlock, bitWriter: BitWriter) =
33 bitWriter.writeSeq(rawBlock.bitLength, rawBlock.data) 33 bitWriter.writeSeq(rawBlock.bitLength, rawBlock.data)
34 34
35proc readRaw*(bitReader: BitReader, bits: int = maxDataBitLength): RawBlock = 35proc readRaw*(bitReader: BitReader, bits: int = maxDataBitLength): RawBlock =
36 let data = readSeq(bitReader, bits, uint8) 36 let data = bitReader.readSeq(bits, uint8)
37 RawBlock(bitLength: data.bitLength, data: data.data) 37 RawBlock(bitLength: data.bitLength, data: data.data)
38 38
39proc writeRawTo*(rawBlock: RawBlock, bitWriter: BitWriter) = 39proc writeRawTo*(rawBlock: RawBlock, bitWriter: BitWriter) =