Generating Peer synchronization issue

Having issues with your Timekoin Server? Someone might be able to answer your questions here.
User avatar
Site Admin
Posts: 1019
Joined: Thu Feb 23, 2012 5:03 pm

Re: Generating Peer synchronization issue

Post by KnightMB »

It has been a while, but I do remember what this issue was and it was fixed a while back.

Take for example (nice round numbers), you have 10 peers. Your server polls all 10 and finds that more than half (6 in this case) do not agree with your list of servers that are allowed to create currency. Before, Timekoin considered no response as a "peer disagrees with me". This could be caused by network error, peer is too busy, peer has unknown error, etc. So those 6 peers might be a network error or maybe on a few of them were. Either way, Timekoin before would consider it a "majority think I am wrong" scenario. In which case, it clears the Generation List and polls these peers to get a new list. Afterwards, it compares the new list to those 6 peers (plus the other 4), but again, say something is not giving a valid response. Maybe only 4 of them agree with the new list. Well Timekoin again assumes "majority think I am wrong" again scenario and process starts over. In the mean time, it is messing with currency generation (server is flipping between elected and not-elected all the time). It was also possible that none of the peers actually disagreed with your list, but the error response made Timekoin think they did, it considered no response/error response as the "disagree" state.

Timekoin was updated to change that logic. If you have 10 peers, each response is only valid if complete (no errors, blank, corrupted responses). So for Timekoin to consider now "majority think I am wrong", it needed to have a valid response from all 6 peers that said it was wrong, not assume it was wrong. The code below in the genpeer.php file was updated to reflect that new logic. Even after the peer was being counted as "you think I am wrong", another failsafe was put in to check the string length of the response (errors would produce 0 byte strings, corrupted answers could be shorter or longer than 32 bytes) So if the answer was not exactly 32 bytes long, it was ignored.

Code: Select all

// Make sure both the response exist and that no connection error occurred
if(strlen($poll_peer) == 32)

	$hash_different["ip_address$gen_list_hash_different"] = $ip_address;
	$hash_different["domain$gen_list_hash_different"] = $domain;
	$hash_different["subfolder$gen_list_hash_different"] = $subfolder;
	$hash_different["port_number$gen_list_hash_different"] = $port_number;				
Having more active peers does negate the problem somewhat because it takes more peers to tell your server "you are wrong" to make it do something. When you have a short list of peers, then it takes fewer peers to disagree and trigger Timekoin into thinking something is wrong and needs to fixed.

As far as changing the majority setting, it wouldn't break the protocol to have it require 2/3 of the peers to trigger a change for example. It could even be a server setting that the administrator could pick (set a percentage above 51% to trigger a refresh for example). It would take some testing and study to see what affect it would have if all servers were using 2/3 instead of 51% to trigger a refresh. The only negative I could see is if the threshold is set to high, you server will be so stubborn that it will never adjust to any needed changes.
User avatar
Posts: 186
Joined: Fri Apr 12, 2013 10:39 am

Re: Generating Peer synchronization issue

Post by PoisonWolf »

Thank you for explaining the fix. Good to know it is fixed. If we only have 100 elected servers to test if it works, that would be awesome.
Post Reply