Skip to content

Commit

Permalink
Clean up old unused code and unused imports (#877)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeme committed Oct 22, 2021
1 parent 92dfb02 commit 02e8b2e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 237 deletions.
2 changes: 1 addition & 1 deletion fluffy/network/history/history_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import
std/[options, sugar],
stew/[results, byteutils],
stew/results,
eth/p2p/discoveryv5/[protocol, node, enr],
../../content_db,
../wire/portal_protocol,
Expand Down
207 changes: 0 additions & 207 deletions fluffy/network/history/messages.nim

This file was deleted.

29 changes: 2 additions & 27 deletions fluffy/network/state/state_content.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
{.push raises: [Defect].}

import
std/[options, sugar],
std/options,
nimcrypto/[sha2, hash], stew/objects, stint,
eth/ssz/ssz_serialization, eth/trie/[hexary, db],
eth/ssz/ssz_serialization,
../../common/common_types

export ssz_serialization, common_types
Expand Down Expand Up @@ -80,28 +80,3 @@ func toContentId*(contentKey: ByteList): ContentId =

func toContentId*(contentKey: ContentKey): ContentId =
toContentId(encode(contentKey))

type
ContentStorage* = object
# TODO: Quick implementation for now where we just use HexaryTrie, current
# idea is to move in here a more direct storage of the trie nodes, but have
# an `ContentProvider` "interface" that could provide the trie nodes via
# this direct storage, via the HexaryTrie (for full nodes), or also without
# storage, via json rpc client requesting data from a full eth1 client.
trie*: HexaryTrie

proc get*(storage: ContentStorage, key: ContentKey): Option[seq[byte]] =
if storage.trie.db == nil: # TODO: for now...
return none(seq[byte])
let val = storage.trie.db.get(key.nodeHash.data)
if val.len > 0:
some(val)
else:
none(seq[byte])

proc get*(storage: ContentStorage, contentKey: ByteList): Option[seq[byte]] =
decode(contentKey).flatMap((key: ContentKey) => get(storage, key))

proc newEmptyInMemoryStorage*(): ContentStorage =
let trie = initHexaryTrie(newMemoryDb())
ContentStorage(trie: trie)
2 changes: 1 addition & 1 deletion fluffy/network/state/state_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import
std/[options, sugar],
stew/[results, byteutils],
stew/results,
eth/p2p/discoveryv5/[protocol, node, enr],
../../content_db,
../wire/portal_protocol,
Expand Down
2 changes: 1 addition & 1 deletion fluffy/tests/test_portal_wire_protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{.used.}

import
chronos, testutils/unittests, stew/shims/net, stew/byteutils,
chronos, testutils/unittests, stew/shims/net,
eth/keys, eth/p2p/discoveryv5/routing_table, nimcrypto/[hash, sha2],
eth/p2p/discoveryv5/protocol as discv5_protocol,
../network/wire/portal_protocol,
Expand Down

0 comments on commit 02e8b2e

Please sign in to comment.