Question for peercoin devs

Hi everybody,

Could someone explain to me what do these few pieces of code do:

Thanx for your help.

EDIT:

Found the related commits:

[ul][li]https://github.com/ppcoin/ppcoin/commit/851fe4f82c9400ced6d58f6f279bc01539d8a1f9[/li]
[li]https://github.com/ppcoin/ppcoin/commit/2f0390f03812ebcf37e592d76ff00204db95d65d[/li]
[li]https://github.com/ppcoin/ppcoin/commit/9e9510fce6ceb5d9d8409fe161c8116615382efa[/li][/ul]

EDIT2:

Useful git command to get the history of a specific selection of lines in a file (since Git 1.8.4):

[tt]git log --pretty=short -u -L 2910,2910:main.cpp[/tt]

[tt]WARNING: terminal is not fully functional
commit 2f0390f03812ebcf37e592d76ff00204db95d65d
Author: Sunny King

PPCoin: Fix initial block download stuck issue

diff --git a/src/main.cpp b/src/main.cpp
— a/src/main.cpp
+++ b/src/main.cpp
@@ -2848,0 +2848,1 @@

  •                    // ppcoin: send latest proof-of-work block to allow the
    

[/tt]

EDIT3: Trying to mention [member=79]Sunny King[/member] and [member=30141]sigmike[/member]

I’m bumping the previous post coz it looks like I have some strange things going on in ppcd probably related to it, like some rejected blocks because already existing and so.

Please [member=30141]sigmike[/member] and [member=79]Sunny King[/member], thanx for your answers.

Ok, I think I got the first one:

If you rejected a valid block for duplicate stake, your “supposed” best chain will get invalidated some time in the future. Meanwhile all the following valid blocks are getting orphaned. To re-attach the valid orphaned blocks to the main chain, you will have to refetch the dup-stake block you rejected, and it is the parent of the oldest orphan block you have.

Did I get it right? You can just say yes or no :wink:

Hard to test coz I still haven’t met such a dup-stake rejected block yet in testnet. I guess it might get impacted by sigmike solution for handling nothing-at-stake (both blocks would get rejected).

Any way, still need to find out for the others few lines of code.

[quote=“mably, post:3, topic:3509”]https://github.com/ppcoin/ppcoin/blob/v0.4.0ppc/src/main.cpp#L2052

If you rejected a valid block for duplicate stake, your “supposed” best chain will get invalidated some time in the future. Meanwhile all the following valid blocks are getting orphaned. To re-attach the valid orphaned blocks to the main chain, you will have to refetch the dup-stake block you rejected, and it is the parent of the oldest orphan block you have.

Did I get it right? You can just say yes or no ;)[/quote]

I’m not certain about the reasoning behind it but yes, all this code does it to ask explicitly for the parent of the oldest block in the orphan chain.

During initial download Peercoin uses the last Proof of Work block as reference because Proof of Stake blocks are ignored if the CoinStake input is not found. So when you receive a recent Proof of Stake block you don’t store it as orphan and the download process fails. That’s something we had to fix in Peershares:

This is probably to make the download process continue after the latest Proof of Work block has been received (because it’s the one used as reference, so the downloading peer doesn’t know anything about the following Proof of Stake blocks).

Thanx a lot [member=30141]sigmike[/member] for your informative answer.