blocks = []
_, _, files = next(walk(self.utils.dir))
for i in range(len(files)):
try:
with open(self.utils.dir + '/nofifty_' + str(i) + '.json') as nofifty:
blocks.append(nofifty.read())
except FileNotFoundError:
with open(self.utils.dir + '/genesis.json') as genesis:
blocks.append(genesis.read())
finally:
for idx, block in enumerate(blocks):
print(idx)
print(block)
self.blocks = [copy.copy(Block.from_json(copy.copy(block))) for block in blocks]
for idx, block in enumerate(self.blocks):
print(idx)
print(block.haschash)
This is an issue tracker for bugs on the Python.org website, not a help desk to ask questions about Python.
In the future, please ask these sorts of questions on the many different forums which are intended for asking for help. Go to the Python.org website and click on the Community menu to see various forums, mailing lists and IRC channels were you can ask for help. Or you can try Reddit's r/learnpython.
I convert my json to python objects in the following way
and the following code
produces the following output
so the hash has the hash of the latest appended block and not the hash of the genesis block
Am i doing something wrong?
also see
https://stackoverflow.com/questions/69781050/append-is-replacing-when-converting-from-json
i did not have this problem with jsonpickle but couldn't encode and decode over and over again because of ignoring fields
see:
https://stackoverflow.com/questions/69770625/how-to-create-a-custom-serialization-handler
python version
Python 3.9.7
The text was updated successfully, but these errors were encountered: