This commit is contained in:
Dmitriy Ryajov 2021-08-27 15:37:24 -06:00
parent baa5fd78a0
commit 47ca93f18c
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
4 changed files with 18 additions and 6 deletions

12
dagger/blockstream.nim Normal file
View File

@ -0,0 +1,12 @@
## Nim-Dagger
## Copyright (c) 2021 Status Research & Development GmbH
## Licensed under either of
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
## * MIT license ([LICENSE-MIT](LICENSE-MIT))
## at your option.
## This file may not be copied, modified, or distributed except according to
## those terms.
import ./blockstream/[blockstream, chunkedblockstream]
export blockstream, chunkedblockstream

View File

@ -13,7 +13,7 @@ import pkg/questionable
import pkg/questionable/results
import ./blockstream
import ./chunker
import ../chunker
type
ChunkedBlockStreamRef* = ref object of BlockStreamRef
@ -22,7 +22,7 @@ type
method nextBlock*(c: ChunkedBlockStreamRef): ?!Block =
let data: seq[byte] = c.chunker.getBytes()
if data.len > 0:
return success Block.new(data)
return Block.new(data)
proc new*(T: type ChunkedBlockStreamRef, chunker: Chunker): T =
func new*(T: type ChunkedBlockStreamRef, chunker: Chunker): T =
T(chunker: chunker)

View File

@ -23,7 +23,7 @@ proc `$`*(b: Block): string =
result &= "cid: " & $b.cid
result &= "\ndata: " & string.fromBytes(b.data)
proc new*(
func new*(
T: type Block,
data: openArray[byte] = [],
version = CIDv1,
@ -34,7 +34,7 @@ proc new*(
cid: Cid.init(version, codec, hash).get(),
data: @data)
proc new*(
func new*(
T: type Block,
cid: Cid,
data: openArray[byte] = [],

View File

@ -70,7 +70,7 @@ iterator items*(c: Chunker): seq[byte] =
yield chunk
proc new(
func new(
T: type Chunker,
kind = ChunkerType.SizedChunker,
reader: Reader,