MetacoSA / QBitNinja

An Open Source and powerful blockchain API
MIT License
68 stars 42 forks source link

After INIT, Listen always throws: Only the genesis block can have no previous block #38

Closed everyonce closed 6 years ago

everyonce commented 6 years ago

I've done this three times, run init (on multiple machine with the same app.config and executable) - and then when it completes initial indexing, and I try to run "listen" on a single instance, it always throws this error. Any insight? I'm glad to provide whatever additional information I can.

NicolasDorier commented 6 years ago

Do you have a stacktrace?

NicolasDorier commented 6 years ago

I always hosted the front end on a Azure website, as it makes it easy to configure scaling/SSL Everywhere, never used --Listen. I would advise you to do the same, this is not complicated. But I can look about your error. Are you using mainnet?

everyonce commented 6 years ago

Yes, mainnet - How do you ensure your Azure Table Storage stays current without running --Listen ? It seems to me that's the only thing listening to the full node (bitcoind)?

Here's the trace, the error happens on QbitNinjaNodeListener.cs line 121: client.SynchronizeChain(chain); I can access runtime vars, etc, from the debugger (i think) if you're looking for anything in particular:

System.ArgumentException occurred HResult=0x80070057 Message=Only the genesis block can have no previous block Source=<Cannot evaluate the exception source> StackTrace: at NBitcoin.ChainedBlock..ctor(BlockHeader header, uint256 headerHash, ChainedBlock previous) at NBitcoin.Indexer.ChainChangeEntryExtensions.UpdateChain(IEnumerable``1 entries, ChainBase chain) at NBitcoin.Indexer.IndexerClient.SynchronizeChain(ChainBase chain) at QBitNinja.Notifications.QBitNinjaNodeListener.Listen(ConcurrentChain chain) in D:\Programs\QBitNinja-1.0.3.44\QBitNinja\Notifications\QBitNinjaNodeListener.cs:line 121 at QBitNinja.Listener.Console.Program.Main(String[] args) in D:\Programs\QBitNinja-1.0.3.44\QBitNinja.Listener.Console\Program.cs:line 113

NicolasDorier commented 6 years ago

I am sorry , --Listen is needed, I confused it with --Web.

NicolasDorier commented 6 years ago

One second, looking. Sometimes this table can get corrupt, even if rare. This is not a big deal though (no need to reindex everything, you can normally just clear the table and it will reindex it fast) I am checking.

NicolasDorier commented 6 years ago

Ok so try this: Just before SynchronizeChain run this only once.

client.Configuration.GetChainTable().DeleteIfExists();

Then close the program.

You may have to wait 5 after closing so that Azure properly clean the table. Then restart again. It should be fine then.

everyonce commented 6 years ago

Would it work the same just to log into Azure and delete my chain table? (is it "chain" or "chainchache"?) (it's just chain - answered my own)

everyonce commented 6 years ago

this seems to have fixed it. is the transaction table/etc still ok even if this thing dies and restarts, etc, or if i delete the chain table as needed?

NicolasDorier commented 6 years ago

@everyonce yes, actually the front end of QBitNinja (the QBitNinja website) already does that when it starts as you can see here.

It should not happen often, and has no noticeable side effect. This table is nothing more than the chain of headers, which is retrieved again and reindexed by the indexer everytimes a block is found anyway.

I have yet to find what cause the corruption.

Also this table is read only once the app start, never after.

everyonce commented 6 years ago

cool, thanks for your help!!