Re:How to Build Your Own Blockchain Part 3 – Writing Nodes T...
by swalsh on Saturday November 04, 2017 @10:27PM
(#15627885)
Small nitpick, I ran the example and found I could only create 3 blocks. (I'm on ubuntu if that matters) looking more into it, it seems like the issues is the glob.glob in sync.py is not always read in order so the chain is out of order. My solution was to move the add block to chain call lower, and to sort the blocks first. After changing that code it seemed to work fine.
[ Parent
| on HN ]
Re:How to Build Your Own Blockchain Part 3 – Writing Nodes T...
by jackschultz on Saturday November 04, 2017 @10:58PM
(#15627974)
Ahh yeah, on a Mac, using os.list_dir leaves 10.json ahead of 2.json. I heard from someone else on Linux that had that problem. If you have the code that works would you make a pull request and I'll throw that in?
Re:How to Build Your Own Blockchain Part 3 – Writing Nodes T...
by aisofteng on Sunday November 05, 2017 @12:51AM
(#15628207)
This is pretty universal. Use lexicographic sorting.
Re:How to Build Your Own Blockchain Part 3 – Writing Nodes T...
by jackschultz on Sunday November 05, 2017 @01:26AM
(#15628286)
Well yes. That's why I put at least 6 characters of 0 in front of the index of a block,so the filenames were 000001.json, and used glob rather than list_dir. But that didn't work for Linux.