Author Topic: a solution for hot standby(From BitSuperLab)  (Read 6382 times)

0 Members and 1 Guest are viewing this topic.

Offline sfinder

  • Hero Member
  • *****
  • Posts: 1205
  • 4 Cores CPU+100GB SSD+anti-DDoS Pro
    • View Profile
nice.i will try this out
hi, delegates. we have a solution for hot standby.

set up delegate wallet in 2 machines. one is master, and the other is slave.
master run  delegate_loop task at seconds 0,10,20 ....
slave run the task with 5 seconds delay, at 5, 15, 25 .....
Normally master will generate block in time, slave will receive the block less than 5 seconds, than slave will not generate block.
If for some reason, master missed generation, slave didn't receive block from master in 5 seconds, slave will generate.

here is the patch for slave program:
Code: [Select]
--- a/libraries/client/client.cpp
+++ b/libraries/client/client.cpp
@@ -729,6 +729,7 @@ config load_config( const fc::path& datadir )
 
           uint32_t slot_number = blockchain::get_slot_number( now );
           time_point_sec next_slot_time = blockchain::get_slot_start_time( slot_number + 1 );
+          next_slot_time += 5;
           ilog( "Rescheduling delegate loop for time: ${t}", ("t",next_slot_time) );
 
           time_point scheduled_time = next_slot_time;
微博:星在飘我在找|BTS X 受托人delegate ID:baidu
中国教育书店合作将20%收入捐献给贫困山区学生。
Cooperating with China Education Bookstore and will donate 20% of delegate income to the poor students

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
Awesome! Never miss a block anymore ..

i guess best practice for the beginning would be to directly connect the mashines to each other

When will this patch be on github?
yes, should add node to the other side.
If it's ok to run like this, maybe we should have a parameter(from 0 to 5)  to setup the delay time.
« Last Edit: July 30, 2014, 05:59:00 am by alt »

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Awesome! Never miss a block anymore ..

i guess best practice for the beginning would be to directly connect the mashines to each other

When will this patch be on github?

Offline HackFisher

  • Hero Member
  • *****
  • Posts: 883
    • View Profile
 +5%  +5%

I want to clarify again that for anyone who are going to try this code, please pay attention that there are *two* nodes, master and slave, with different schedule times but the same slot time!

Looking forward more review ...
« Last Edit: July 30, 2014, 06:05:31 am by HackFisher »
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
hi, delegates. we have a solution for hot standby.

set up delegate wallet in 2 machines. one is master, and the other is slave.
master run  delegate_loop task at seconds 0,10,20 ....
slave run the task with 5 seconds delay, at 5, 15, 25 .....
Normally master will generate block in time, slave will receive the block less than 5 seconds, than slave will not generate block.
If for some reason, master missed generation, slave didn't receive block from master in 5 seconds, slave will generate.

here is the patch for slave program:
Code: [Select]
--- a/libraries/client/client.cpp
+++ b/libraries/client/client.cpp
@@ -729,6 +729,7 @@ config load_config( const fc::path& datadir )
 
           uint32_t slot_number = blockchain::get_slot_number( now );
           time_point_sec next_slot_time = blockchain::get_slot_start_time( slot_number + 1 );
+          next_slot_time += 5;
           ilog( "Rescheduling delegate loop for time: ${t}", ("t",next_slot_time) );
 
           time_point scheduled_time = next_slot_time;