From 47ca93f18c45029a940816f6d7e5e9e1af1be64c Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 27 Aug 2021 15:37:24 -0600 Subject: [PATCH] wip --- dagger/blockstream.nim | 12 ++++++++++++ dagger/blockstream/chunkedblockstream.nim | 6 +++--- dagger/blocktype.nim | 4 ++-- dagger/chunker.nim | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 dagger/blockstream.nim diff --git a/dagger/blockstream.nim b/dagger/blockstream.nim new file mode 100644 index 00000000..cb7601ce --- /dev/null +++ b/dagger/blockstream.nim @@ -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 diff --git a/dagger/blockstream/chunkedblockstream.nim b/dagger/blockstream/chunkedblockstream.nim index 49b6b6f5..beddd77e 100644 --- a/dagger/blockstream/chunkedblockstream.nim +++ b/dagger/blockstream/chunkedblockstream.nim @@ -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) diff --git a/dagger/blocktype.nim b/dagger/blocktype.nim index 8d64fdab..c4e65afd 100644 --- a/dagger/blocktype.nim +++ b/dagger/blocktype.nim @@ -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] = [], diff --git a/dagger/chunker.nim b/dagger/chunker.nim index e42fe0da..a5ae36af 100644 --- a/dagger/chunker.nim +++ b/dagger/chunker.nim @@ -70,7 +70,7 @@ iterator items*(c: Chunker): seq[byte] = yield chunk -proc new( +func new( T: type Chunker, kind = ChunkerType.SizedChunker, reader: Reader,