Browse Source

Allow use Hardcoded RandomHash table on GUI

Note: This example will read a hardcoded RandomHash table based on UConst values if the files are available on the system (nothing if file not found)
PascalCoin 6 years ago
parent
commit
36d5a9309a
2 changed files with 15 additions and 0 deletions
  1. 3 0
      src/core/UConst.pas
  2. 12 0
      src/gui-classic/UFRMWallet.pas

+ 3 - 0
src/core/UConst.pas

@@ -153,6 +153,9 @@ Const
 
 
   CT_Protocol_v3_PIP11_Percent = 20; // PIP-0011 20% Percent proposed and voted by PIP-0011
   CT_Protocol_v3_PIP11_Percent = 20; // PIP-0011 20% Percent proposed and voted by PIP-0011
 
 
+  CT_Hardcoded_RandomHash_Table_Filename = 'HardcodedRH_63300.randomhash';
+  CT_Hardcoded_RandomHash_Table_HASH = '1908BAB3D3A2EF04ECA9F0AEE9E2BD6423D2A921B5880A1CBA8A748D11424418';
+
   CT_PseudoOpSubtype_Miner                = 1;
   CT_PseudoOpSubtype_Miner                = 1;
   CT_PseudoOpSubtype_Developer            = 2;
   CT_PseudoOpSubtype_Developer            = 2;
 
 

+ 12 - 0
src/gui-classic/UFRMWallet.pas

@@ -376,19 +376,31 @@ end;
 
 
 procedure TThreadActivate.BCExecute;
 procedure TThreadActivate.BCExecute;
 Var currentProcess : String;
 Var currentProcess : String;
+  LTC : TTickCount;
+  LRaw : TRawBytes;
 begin
 begin
   FLastTC := 0;
   FLastTC := 0;
   FLastMsg := '';
   FLastMsg := '';
+  //
+  OnProgressNotify(Self,'Reading Hardcoded RandomHash file',0,0);
+  LRaw := TCrypto.HexaToRaw(CT_Hardcoded_RandomHash_Table_HASH);
+  TPascalCoinProtocol.AllowUseHardcodedRandomHashTable(
+    TFolderHelper.GetPascalCoinDataFolder+PathDelim+'Data'+PathDelim+CT_Hardcoded_RandomHash_Table_Filename,
+    LRaw );
   // Read Operations saved from disk
   // Read Operations saved from disk
   TNode.Node.InitSafeboxAndOperations($FFFFFFFF,OnProgressNotify); // New Build 2.1.4 to load pending operations buffer
   TNode.Node.InitSafeboxAndOperations($FFFFFFFF,OnProgressNotify); // New Build 2.1.4 to load pending operations buffer
   TNode.Node.AutoDiscoverNodes(CT_Discover_IPs);
   TNode.Node.AutoDiscoverNodes(CT_Discover_IPs);
   TNode.Node.NetServer.Active := true;
   TNode.Node.NetServer.Active := true;
   FLastTC := 0;
   FLastTC := 0;
   FLastMsg := '';
   FLastMsg := '';
+  LTC := TPlatform.GetTickCount;
   if (TNode.Node.Bank.BlocksCount<=1) then begin
   if (TNode.Node.Bank.BlocksCount<=1) then begin
     while (Not Terminated) And (Not TNode.Node.IsReady(currentProcess) Or (TNode.Node.Bank.BlocksCount<=1)) do begin
     while (Not Terminated) And (Not TNode.Node.IsReady(currentProcess) Or (TNode.Node.Bank.BlocksCount<=1)) do begin
       Synchronize(ThreadSafeNotify);
       Synchronize(ThreadSafeNotify);
       Sleep(200);
       Sleep(200);
+      {$IFDEF TESTNET}
+      if (TPlatform.GetElapsedMilliseconds(LTC)>5000) then Break;
+      {$ENDIF}
     end;
     end;
   end;
   end;
   if Not Terminated then begin
   if Not Terminated then begin