py-evm icon indicating copy to clipboard operation
py-evm copied to clipboard

allow db implementations to have iterable views

Open charles-cooper opened this issue 3 years ago • 0 comments

What is wrong?

currently, an AtomicDB cannot be iterated over. this makes it tricky to inspect, ex.

>>> t.env.vm.state._db.items()
ItemsView(<eth.db.atomic.AtomicDB object at 0x7fdf23f260e0>)
>>> list(t.env.vm.state._db.items())
NotImplementedError: By default, DB classes cannot return the total number of keys.

How can it be fixed

probably, add __iter__ and __len__ methods to all useful db classes

charles-cooper avatar Jun 29 '22 23:06 charles-cooper