remove a lot of XDeclaredButNotUsed spam from SSZ

This commit is contained in:
Mamy André-Ratsimbazafy 2019-11-06 11:36:05 +01:00 committed by zah
parent e8a64e4206
commit 5f6d60abce
2 changed files with 4 additions and 12 deletions

View File

@ -46,8 +46,6 @@ type
totalChunks: uint64
limit: uint64
Chunk = array[bytesPerChunk, byte]
TypeWithMaxLen*[T; maxLen: static int64] = distinct T
SizePrefixed*[T] = distinct T
@ -130,7 +128,7 @@ func writeFixedSized(c: var WriteCursor, x: auto) =
else: unsupported x.type
c.append bytes
else:
let valueAddr = unsafeAddr x
let valueAddr {.used.} = unsafeAddr x
trs "APPENDING INT ", x, " = ", makeOpenArray(cast[ptr byte](valueAddr), sizeof(x))
c.appendMemCopy x
elif x is StUint:
@ -266,10 +264,6 @@ func writeValue*[T](w: var SszWriter, x: SizePrefixed[T]) =
buf.appendVarint length
cursor.writeAndFinalize buf.writtenBytes
template checkEof(n: int) =
if not r.stream[].ensureBytes(n):
raise newException(UnexpectedEofError, "SSZ has insufficient number of bytes")
template fromSszBytes*(T: type BlsValue, bytes: openarray[byte]): auto =
fromBytes(T, bytes)
@ -456,7 +450,7 @@ template merkelizeFields(body: untyped): Eth2Digest {.dirty.} =
addChunk(merkelizer, hash.data)
trs "CHUNK ADDED"
template addField2(field) =
template addField2(field) {.used.}=
const maxLen = fieldMaxLen(field)
when maxLen > 0:
type FieldType = type field
@ -492,7 +486,6 @@ func bitlistHashTreeRoot(merkelizer: SszChunksMerkelizer, x: BitSeq): Eth2Digest
var
bytesInLastChunk = totalBytes mod bytesPerChunk
paddingBytes = bytesPerChunk - bytesInLastChunk
fullChunks = totalBytes div bytesPerChunk
if bytesInLastChunk == 0:

View File

@ -61,9 +61,9 @@ proc fromSszBytes*[N](T: type BitList[N], bytes: openarray[byte]): auto =
proc readSszValue*(input: openarray[byte], T: type): T =
mixin fromSszBytes, toSszType
type T = type(result)
type T {.used.}= type(result)
template readOffset(n: int): int =
template readOffset(n: int): int {.used.}=
int fromSszBytes(uint32, input[n ..< n + offsetSize])
when useListType and result is List:
@ -158,4 +158,3 @@ proc readSszValue*(input: openarray[byte], T: type): T =
else:
unsupported T