mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-16 14:57:54 +00:00
wip
This commit is contained in:
parent
baa5fd78a0
commit
47ca93f18c
12
dagger/blockstream.nim
Normal file
12
dagger/blockstream.nim
Normal 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
|
@ -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)
|
||||
|
@ -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] = [],
|
||||
|
@ -70,7 +70,7 @@ iterator items*(c: Chunker): seq[byte] =
|
||||
|
||||
yield chunk
|
||||
|
||||
proc new(
|
||||
func new(
|
||||
T: type Chunker,
|
||||
kind = ChunkerType.SizedChunker,
|
||||
reader: Reader,
|
||||
|
Loading…
x
Reference in New Issue
Block a user