Pages:
Author

Topic: .NET Blockchain Parser - page 2. (Read 4657 times)

hero member
Activity: 714
Merit: 661
November 21, 2014, 09:40:45 PM
#9
For NBitcoin, the interesting part for you is the "Manual scanning" from http://www.codeproject.com/Articles/784519/NBitcoin-How-to-scan-the-Blockchain

Quote
Install-Package NBitcoin

then,
Quote
BlockStore store = new BlockStore("E:\\Bitcoin\\blocks", Network.Main);
foreach(var block in store.Enumerate())
{
...
}

If needed, you can index block headers and blocks location in the directory into an SqlLite database as explained in the article.

Quote
Agree, specially if that project can have decent tests and be modular. http://bitcoinj.github.io/ (http://bitcoinj.github.io/) is a good example how it should be done, it's so good that many developers recommend it over bitcoind reference implementation for use in corporate environments.

Not for throwing flower to myself, but NBitcoin largely match it, and is spreading fast these days. Wink
legendary
Activity: 1974
Merit: 1076
^ Will code for Bitcoins
November 21, 2014, 10:26:48 AM
#8
While we are at this subject, there are two remarkable and similar C# previous projects:
- http://www.codeproject.com/Articles/784519/NBitcoin-How-to-scan-the-Blockchain (large and in detail)
- https://github.com/kria/BlockChainParser (more like this one)

Except these two, there are two excellent code projects in C which also work directly on the blockchain without the RPC interface:
- http://codesuppository.blogspot.com/2013/07/bitcoin-code-snippets.html (you've mentioned John Ratcliff on GitHub page)
- https://github.com/mcdee/blockparser (lightning fast and very useful, but demands 8GB of RAM)

Hope this helps.
Good tips, I've re-written a lot of code just so I get a good understanding of how it works.  Would be good if people contributed to one c# project and make that rock solid, rather than a lot of half baked ones :S

Agree, specially if that project can have decent tests and be modular. http://bitcoinj.github.io/ is a good example how it should be done, it's so good that many developers recommend it over bitcoind reference implementation for use in corporate environments.
hero member
Activity: 765
Merit: 503
November 20, 2014, 06:43:53 PM
#7
While we are at this subject, there are two remarkable and similar C# previous projects:
- http://www.codeproject.com/Articles/784519/NBitcoin-How-to-scan-the-Blockchain (large and in detail)
- https://github.com/kria/BlockChainParser (more like this one)

Except these two, there are two excellent code projects in C which also work directly on the blockchain without the RPC interface:
- http://codesuppository.blogspot.com/2013/07/bitcoin-code-snippets.html (you've mentioned John Ratcliff on GitHub page)
- https://github.com/mcdee/blockparser (lightning fast and very useful, but demands 8GB of RAM)

Hope this helps.
Good tips, I've re-written a lot of code just so I get a good understanding of how it works.  Would be good if people contributed to one c# project and make that rock solid, rather than a lot of half baked ones :S
legendary
Activity: 1974
Merit: 1076
^ Will code for Bitcoins
November 20, 2014, 03:10:20 PM
#6
While we are at this subject, there are two remarkable and similar C# previous projects:
- http://www.codeproject.com/Articles/784519/NBitcoin-How-to-scan-the-Blockchain (large and in detail)
- https://github.com/kria/BlockChainParser (more like this one)

Except these two, there are two excellent code projects in C which also work directly on the blockchain without the RPC interface:
- http://codesuppository.blogspot.com/2013/07/bitcoin-code-snippets.html (you've mentioned John Ratcliff on GitHub page)
- https://github.com/mcdee/blockparser (lightning fast and very useful, but demands 8GB of RAM)

Hope this helps.
hero member
Activity: 765
Merit: 503
November 19, 2014, 11:02:25 PM
#5
Ill make a pull request tonight, but here's some feedback.

  • No Unit tests, the base 58 class is ideal to unit test and important its tested.
  • Parts are really Models IMO
  • I would make BlockchainToSql a class library so we can use it in our projects
  • Separate the SQL code out, to maybe a provider.  Then inject the provider using something like IRepsoitory interface.  This will enable devs to write providers for other databases etc.
  • For timings, use System.Diagnostics.Stopwatch class instead of Date.UtcNow
  • Not sure why you are explicitly calling dbContext.Dispose(), when you are using a "using"

Good work tho!  Need some c# code for peer to peer getwork stuff now.

@doof, I agree with all what you say, of course. It's just that I prefer to share earlier code than share better code.

Happy to help work on this project, I need something similar.  Also need to change the models to have properties instead of vars.
full member
Activity: 164
Merit: 126
Amazing times are coming
November 19, 2014, 09:55:28 PM
#4
Ill make a pull request tonight, but here's some feedback.

  • No Unit tests, the base 58 class is ideal to unit test and important its tested.
  • Parts are really Models IMO
  • I would make BlockchainToSql a class library so we can use it in our projects
  • Separate the SQL code out, to maybe a provider.  Then inject the provider using something like IRepsoitory interface.  This will enable devs to write providers for other databases etc.
  • For timings, use System.Diagnostics.Stopwatch class instead of Date.UtcNow
  • Not sure why you are explicitly calling dbContext.Dispose(), when you are using a "using"

Good work tho!  Need some c# code for peer to peer getwork stuff now.

@doof, I agree with all what you say, of course. It's just that I prefer to share earlier code than share better code.
hero member
Activity: 765
Merit: 503
November 19, 2014, 07:03:12 PM
#3
Ill make a pull request tonight, but here's some feedback.

  • No Unit tests, the base 58 class is ideal to unit test and important its tested.
  • Parts are really Models IMO
  • I would make BlockchainToSql a class library so we can use it in our projects
  • Separate the SQL code out, to maybe a provider.  Then inject the provider using something like IRepsoitory interface.  This will enable devs to write providers for other databases etc.
  • For timings, use System.Diagnostics.Stopwatch class instead of Date.UtcNow
  • Not sure why you are explicitly calling dbContext.Dispose(), when you are using a "using"

Good work tho!  Need some c# code for peer to peer getwork stuff now.
hero member
Activity: 765
Merit: 503
November 19, 2014, 06:53:16 PM
#2
Awesome.  This has been on my todo list for a while.
full member
Activity: 164
Merit: 126
Amazing times are coming
November 19, 2014, 05:52:27 PM
#1
Hi,

I've just uploaded a little project that can parse the blockchain (the raw blk?Huh?.dat files) and returns the block's data (block, transactions, inputs and outputs) while it walks the blockchain. It is a very very simple piece of code and works pretty well.

As an example, in the same github repo there is a tool that reads the blockchain and save its blocks data in a ms sql database. I called it BlockchainToSql. I know there is a similar tool available for MySql but we, the .NET devs, are as we are.

the github repo: https://github.com/lontivero/BlockchainParser

If you find it interesting and want to collaborate then please do it.
Pages:
Jump to: