Closed vonzepp closed 7 years ago
This code works on Bitcoin networks. Problem is only with Litecoin.
node.GetBlocks works fine on Litecoin. I'm able to get some of the latest blocks: http://ltc.blockr.io/block/info/1199773
var block = node.GetBlocks(new []{ new uint256("cf0a4d2bae4d5cf18e657d9347cfa0fe8b141ca037930f05bbb1687c40cea2b6") }, cts.Token)
.FirstOrDefault();
It seems that problem is only with gettting chain of BlockHeaders.
sorry for late reply, I have not seen your issue, I am checking it now.
I just fixed it, turned out Litecoin calculate work differently than bitcoin. Thanks for report, sorry for late reply. Update the package.
chain = connector.Node.GetChain(); <-- with the latest nuget's for nbitcoin and ltc this call just never comes back. Works fine with BTC, not so fine with LTC, any help?
@hawthornetr it should work. The LTC chain is like 4 times bigger than Bitcoin so you need to wait way more.
Hey Nicolas,
I wanted to point out that there was a pretty significant performance difference between these versions, when running against NBitcoin.Litecoin:
v0.0.59
v0.0.65
File in primary project: https://github.com/MetacoSA/NBitcoin/blob/master/NBitcoin/Protocol/Node.cs
Code Line
public IEnumerable<ChainedBlock> SynchronizeChain(ChainBase chain, uint256 hashStop = null, CancellationToken cancellationToken = default(CancellationToken))
{
...
var headers = GetHeadersFromFork(oldTip, options, cancellationToken).ToList(); //<-- this line took a huge performance hit on v0.65, The performance his was not an issue when run against v0.0.59
....
@cybervoid I indeed made some changes recently in this area. Can you try to pass options
and disable PoWCheck and see if it is better?
I tried to create simple SPV client for Litecoin Main network (Test network does not work completely).
Later I checked chain.Height by timer... The latest block I've got was 12095, but it seems that ChainBehavior stucks on that block. chain.Tip.Height = 12095 The block is valid ( http://ltc.blockr.io/block/info/12095 ), but I wait for several minutes and chain.Tip / chain.Height were NOT updated anymore.
Then I tried to disable ChainBehavior and download the chain manually:
I've got the same exception from all connected nodes:
Nodes were:
I attached sample project with my code.