## Nim-LibP2P ## Copyright (c) 2018 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 chronos import types, ../../connection, ../../varint, ../../vbuffer, ../../stream/lpstream, nimcrypto/utils proc readHeader*(conn: Connection): Future[(uint, MessageType)] {.async, gcsafe.} = var header: uint length: int res: VarintStatus var buffer = newSeq[byte](10) try: for i in 0.. 0: buf.writeVarint(LPSomeUVarint(size.uint)) buf.finish() result = conn.write(buf.buffer)