Basicly KGW is just calculating running average, min x hours, up to y days. Then, it limits the max change with the horizon.
This is the alternative:
The average should be weighted so the latest block times affects more than the older block times.
In the simplest theorethical implementation:
Count from the block 0: TimeAverage = (TimeAverage + LastBlockTime)/2Cannot 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;
}
Actually this simulates quite well RC circuits commonly used on electorics to filter signals.
What do you think? I think it is a lot simpler and more effective that KGW.