Skip to content

Commit

Permalink
Reduce declared but not used warnings (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko authored Jan 29, 2025
1 parent 254be32 commit e589cc0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions eth/common/eth_types_rlp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ proc read*(rlp: var Rlp, T: type BlockHashOrNumber): T =
BlockHashOrNumber(isHash: false, number: rlp.read(BlockNumber))

proc rlpHash*[T](v: T): Hash32 =
Hash32(rlp.encodeHash(v))
rlp.encodeHash(v)

proc rlpHash*(tx: PooledTransaction): Hash32 =
Hash32(rlp.encodeHash(tx.tx))
rlp.encodeHash(tx.tx)

func blockHash*(h: Header): Hash32 {.inline.} =
rlpHash(h)
18 changes: 9 additions & 9 deletions eth/rlp/writer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ template appendImpl(self: var RlpWriter, i: SomeUnsignedInt) =
self.appendInt(i)

template appendImpl(self: var RlpWriter, e: enum) =
# TODO: check for negative enums
# TODO: check for negative enums
self.appendInt(uint64(e))

template appendImpl(self: var RlpWriter, b: bool) =
Expand All @@ -73,10 +73,10 @@ template innerType[T](x: Option[T] | Opt[T]): typedesc = T
proc countNestedListsDepth(T: type): int {.compileTime.} =
mixin enumerateRlpFields

var dummy: T
var dummy {.used.}: T

template op(RT, fN, f) =
result += countNestedListsDepth(type f)
template op(RT, fN, f) {.used.}=
result += countNestedListsDepth(type f)

when T is Option or T is Opt:
result += countNestedListsDepth(innerType(dummy))
Expand All @@ -89,7 +89,7 @@ proc countNestedListsDepth(T: type): int {.compileTime.} =
inc result
result += countNestedListsDepth(elementType(dummy))

proc countNestedListsDepth[E](T: type openArray[E]): int =
proc countNestedListsDepth[E](T: type openArray[E]): int =
countNestedListsDepth(seq[E])

proc countOptionalFields(T: type): int {.compileTime.} =
Expand Down Expand Up @@ -209,8 +209,8 @@ proc initRlpList*(listSize: int): RlpDefaultWriter =

proc encode*[T](v: T): seq[byte] =
mixin append
const nestedListsDepth = countNestedListsDepth(T)

const nestedListsDepth = countNestedListsDepth(T)

when nestedListsDepth > 0:
var tracker = StaticRlpLengthTracker[nestedListsDepth]()
Expand All @@ -229,7 +229,7 @@ proc encode*[T](v: T): seq[byte] =
proc encodeHash*[T](v: T): Hash32 =
mixin append

const nestedListsDepth = countNestedListsDepth(T)
const nestedListsDepth = countNestedListsDepth(T)

when nestedListsDepth > 0:
var tracker = StaticRlpLengthTracker[nestedListsDepth]()
Expand All @@ -256,7 +256,7 @@ func encodeInt*(i: SomeUnsignedInt): RlpIntBuf =
let bytesNeeded = uint64(i).bytesNeeded

buf.add(BLOB_START_MARKER + byte(bytesNeeded))
buf.setLen(buf.len + bytesNeeded)
buf.setLen(buf.len + bytesNeeded)
buf.writeBigEndian(i, buf.len - 1, bytesNeeded)

buf
Expand Down

0 comments on commit e589cc0

Please sign in to comment.