mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 22:36:01 +00:00
remove a lot of XDeclaredButNotUsed spam from SSZ
This commit is contained in:
parent
e8a64e4206
commit
5f6d60abce
@ -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:
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user