However, the calculated average block time should be weighted so the latest block times affects more than the older block times. KGW does not do this.
This is the alternative:
In the simplest theorethical implementation:
Count from the block 0: TimeAverage = (TimeAverage + LastBlockTime)/2
Cannot do that in practise; it would weigth the latest block time too much (50%), and also we cannot walk throught the blockchain everytime we start over, so
FilterAttenuation = 8
Walkingblock = (block@heightof(currentblock-(FilterAttenuation*2))
TimeAverage = Walkingblock.time
while Walkingblock.heigth < currentblock.height
{
Walkingblock = Walkingblock.next;
TimeAverage = (TimeAverage*(FilterAttenuation-1) + WalkingblockTime)/FilterAttenuation;
}
What do you think? I think it is a lot simpler and more effective that KGW.
I assume WalkingblockTime is Walkingblock.time.
Interesting algorithm. I agree KGW could be simplified by a weighted average calculation.
It looks like it should work well. One question, why does the algorithm go back 2 * FilterAttenuation blocks and not FilterAttenuation blocks only?