diff --git a/src/blobsets/tcp.nim b/src/blobsets/tcp.nim deleted file mode 100644 index d61bc8c..0000000 --- a/src/blobsets/tcp.nim +++ /dev/null @@ -1,262 +0,0 @@ -import std/asyncnet, std/asyncdispatch, std/streams -import ../blobsets, ./stores - -const - defaultPort = Port(1023) - -proc toInt(chars: openArray[char]): int32 = - for c in chars.items: - result = (result shl 8) or c.int32 - -const maxErrorLen = 128 - -type - Tag = enum - errTag = 0'i16 - getTag = 1 - putTag = 2 - - MessageBody = object {.union.} - error: array[maxErrorLen, char] - putLen: int32 - Message = object {.packed.} - len: int32 - cid: Cid - tag: Tag - body: MessageBody - -const - errMsgBaseSize = 4 + cidSize + 2 - getMsgSize = 4 + cidSize + 2 - putMsgSize = 4 + cidSize + 2 + 4 - minMsgSize = getMsgSize - maxMsgSize = 4 + cidSize + maxErrorLen - -when isMainModule: - doAssert(maxMsgSize == sizeof(msg)) - -proc `$`(msg: Message): string = - result = "[" & $msg.cid & "][" - case msg.tag - of errTag: - result.add "err][" - let n = clamp(msg.len - errMsgBaseSize, 0, maxErrorLen) - for i in 0..