top | item 29936393

Rewriting my toy blockchain in Rust

112 points| kurinikku | 4 years ago |ezzeriesa.notion.site | reply

21 comments

order
[+] davemp|4 years ago|reply
> At this stage, I could spend time optimizing the code. Ideas include (thanks to Andrey Petrov) isolating int-to-byte conversions, using bitmaps to determine leading zero bytes, and reducing allocations by using arrays.

Another easy speed up would be using an intrinsic [0] to count leading zeroes which would just call the lzcnt instruction [1] (or equivalent) and skip the need for a loop for difficulty <=64.

[0]: https://doc.rust-lang.org/std/primitive.u32.html#method.lead...

[1]: https://www.felixcloutier.com/x86/lzcnt

[+] shaneprrlt|4 years ago|reply
How can I buy in, I've got a feeling this is gonna moon, diamond hands all the way. /s/joke
[+] vmception|4 years ago|reply
Copy and paste and just post a notice about it. A few small exchanges will list for free or very cheaply and they’ll typically run a node or two, which helps the initial security of your blockchain.
[+] cableshaft|4 years ago|reply
Connect your crypto wallet, to this completely legit website with a slightly different domain name than the real domain name, add like, 3ETH to your wallet, and agree to the transaction. I promise it's official and you're not approving me taking all the crypto and NFTs out of your wallet.

(Joke, by the way. Although something that can happen if you're not careful).

[+] benatkin|4 years ago|reply
This might help me with my analysis of Solana and Avalanche. Solana supports Rust smart contracts.

First time I tried to load it I got an error, but I'm sure I'll be able to view it sooner or later. Can confirm Notion is not great.

[+] knownjorbist|4 years ago|reply
Polkadot is also Rust-native.
[+] AtlasBarfed|4 years ago|reply
I was ruminating on blockchains today. So, say a coin blockchain from the CAP perspective:

Well, obviously it is distributed, so you want Partition Tolerance.

Well, obviously it is financial, so you need Consistency.

Well, obviously you always want to be able to use it so you need Availability.

But you can only pick two...

[+] PretzelPirate|4 years ago|reply
You only get two, availability and partition tolerance.

Consistency is more akin to an eventual consistency model. There may be two blocks found at the same time that are sent out to the network. At some point, nodes which accepted the minority block will re-org and become consistent with the rest of the network.

Re-orgs are why you wait for X confirmations before trusting that a transaction is finalized.

[+] Kiro|4 years ago|reply
OT but why would anyone create two fresh accounts just to post those two dead/flagged comments?
[+] donkarma|4 years ago|reply

[deleted]

[+] woah|4 years ago|reply
Works OK for me. It's on Notion, a Google Docs competitor that gets heavy usage. Maybe something is wrong with your browser
[+] notfed|4 years ago|reply
What a hacker-news-worthy first comment!

On mobile the website worked great for me. Writing a blockchain is an eye opening task, I commend the OP for doing this and giving us all some inspiration.

[+] nicoburns|4 years ago|reply
Sounds like a perfect metaphor for blockchain applications!