stratisproject / StratisBitcoinFullNode

Bitcoin full node in C#
https://stratisplatform.com
MIT License
787 stars 312 forks source link

Port BitcoinStream serialization improvement from nbitcoin #1871

Open mikedennis opened 6 years ago

mikedennis commented 6 years ago

Several commits related to using span on serialization. span should now be available in .net core 2.1

Spanify some methods https://github.com/MetacoSA/NBitcoin/commit/a2ae05eb2a7b97d0001a75b9f8714e981d6c2265#diff-7dda4c094394789c50086ac0238865a4

Improve perf of uint256 serialization if span is supported. https://github.com/MetacoSA/NBitcoin/commit/8864a47aaf22f11769d65ade609d38d18f90faa7

Remove some allocation during parsing with BitcoinStream https://github.com/MetacoSA/NBitcoin/commit/e8b5f36a9d7b80d8191d36076466d31d62c6e06d#diff-7dda4c094394789c50086ac0238865a4

Might as well do this optimization as well while in there: Do not needlessly create a VarString https://github.com/MetacoSA/NBitcoin/commit/8e17cdf906d79b4373433b52d61b4142396d6041#diff-7dda4c094394789c50086ac0238865a4

Aprogiena commented 6 years ago

Is this not available only in unsafe code?

mikedennis commented 6 years ago

I believe its safe and managed. Here's a good article I found on it https://msdn.microsoft.com/en-us/magazine/mt814808.aspx I think very useful tool for low level stuff and should make porting some C++ bitcoin stuff a bit easier.

Aprogiena commented 6 years ago

Thanks, I will read that

Aprogiena commented 6 years ago

@mikedennis wow, that was an amazing read, thank you