|
@@ -46,6 +46,7 @@ Const
|
|
CT_INI_IDENT_LOWMEMORY = 'LOWMEMORY';
|
|
CT_INI_IDENT_LOWMEMORY = 'LOWMEMORY';
|
|
CT_INI_IDENT_MINPENDINGBLOCKSTODOWNLOADCHECKPOINT = 'MINPENDINGBLOCKSTODOWNLOADCHECKPOINT';
|
|
CT_INI_IDENT_MINPENDINGBLOCKSTODOWNLOADCHECKPOINT = 'MINPENDINGBLOCKSTODOWNLOADCHECKPOINT';
|
|
CT_INI_IDENT_PEERCACHE = 'PEERCACHE';
|
|
CT_INI_IDENT_PEERCACHE = 'PEERCACHE';
|
|
|
|
+ CT_INI_IDENT_DATA_FOLDER = 'DATAFOLDER';
|
|
|
|
|
|
Type
|
|
Type
|
|
{ TPCDaemonThread }
|
|
{ TPCDaemonThread }
|
|
@@ -55,6 +56,7 @@ Type
|
|
FIniFile : TIniFile;
|
|
FIniFile : TIniFile;
|
|
FMaxBlockToRead: Int64;
|
|
FMaxBlockToRead: Int64;
|
|
FLastNodesCacheUpdatedTS : TTickCount;
|
|
FLastNodesCacheUpdatedTS : TTickCount;
|
|
|
|
+ function GetDataFolder : String;
|
|
procedure OnNetDataReceivedHelloMessage(Sender : TObject);
|
|
procedure OnNetDataReceivedHelloMessage(Sender : TObject);
|
|
procedure OnInitSafeboxProgressNotify(sender : TObject; const message : String; curPos, totalCount : Int64);
|
|
procedure OnInitSafeboxProgressNotify(sender : TObject; const message : String; curPos, totalCount : Int64);
|
|
protected
|
|
protected
|
|
@@ -87,7 +89,6 @@ Type
|
|
TPCDaemonMapper = Class(TCustomDaemonMapper)
|
|
TPCDaemonMapper = Class(TCustomDaemonMapper)
|
|
private
|
|
private
|
|
FLog : TLog;
|
|
FLog : TLog;
|
|
- procedure OnPascalCoinInThreadLog(logtype : TLogType; Time : TDateTime; AThreadID : TThreadID; Const sender, logtext : String);
|
|
|
|
protected
|
|
protected
|
|
Procedure DoOnCreate; override;
|
|
Procedure DoOnCreate; override;
|
|
Procedure DoOnDestroy; override;
|
|
Procedure DoOnDestroy; override;
|
|
@@ -105,6 +106,19 @@ Var _FLog : TLog;
|
|
|
|
|
|
{ TPCDaemonThread }
|
|
{ TPCDaemonThread }
|
|
|
|
|
|
|
|
+function TPCDaemonThread.GetDataFolder: String;
|
|
|
|
+Var LIniDataFolder : String;
|
|
|
|
+begin
|
|
|
|
+ LIniDataFolder := FIniFile.ReadString(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_DATA_FOLDER,'').Trim;
|
|
|
|
+ if (LIniDataFolder.Length=0) then begin
|
|
|
|
+ LIniDataFolder:=TNode.GetPascalCoinDataFolder;
|
|
|
|
+ end else begin
|
|
|
|
+ TNode.SetPascalCoinDataFolder(LIniDataFolder);
|
|
|
|
+ end;
|
|
|
|
+ ForceDirectories(LIniDataFolder);
|
|
|
|
+ Result := LIniDataFolder;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TPCDaemonThread.OnNetDataReceivedHelloMessage(Sender: TObject);
|
|
procedure TPCDaemonThread.OnNetDataReceivedHelloMessage(Sender: TObject);
|
|
Var LNsarr : TNodeServerAddressArray;
|
|
Var LNsarr : TNodeServerAddressArray;
|
|
i : Integer;
|
|
i : Integer;
|
|
@@ -154,7 +168,7 @@ var
|
|
TLog.NewLog(ltInfo,ClassName,'RPC server is active on port '+IntToStr(port));
|
|
TLog.NewLog(ltInfo,ClassName,'RPC server is active on port '+IntToStr(port));
|
|
If FIniFile.ReadBool(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_RPC_SAVELOGS,true) then begin
|
|
If FIniFile.ReadBool(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_RPC_SAVELOGS,true) then begin
|
|
FIniFile.WriteBool(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_RPC_SAVELOGS,true);
|
|
FIniFile.WriteBool(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_RPC_SAVELOGS,true);
|
|
- FRPC.LogFileName:= TNode.GetPascalCoinDataFolder+PathDelim+'pascalcoin_rpc.log';
|
|
|
|
|
|
+ FRPC.LogFileName:= GetDataFolder+PathDelim+'pascalcoin_rpc.log';
|
|
TLog.NewLog(ltInfo,ClassName,'Activating RPC logs on file '+FRPC.LogFileName);
|
|
TLog.NewLog(ltInfo,ClassName,'Activating RPC logs on file '+FRPC.LogFileName);
|
|
end else begin
|
|
end else begin
|
|
FIniFile.WriteBool(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_RPC_SAVELOGS,false);
|
|
FIniFile.WriteBool(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_RPC_SAVELOGS,false);
|
|
@@ -233,12 +247,10 @@ begin
|
|
// Load Node
|
|
// Load Node
|
|
// Check OpenSSL dll
|
|
// Check OpenSSL dll
|
|
if Not LoadSSLCrypt then begin
|
|
if Not LoadSSLCrypt then begin
|
|
- WriteLn('Cannot load '+SSL_C_LIB);
|
|
|
|
- WriteLn('To use this software make sure this file is available on you system or reinstall the application');
|
|
|
|
raise Exception.Create('Cannot load '+SSL_C_LIB+#10+'To use this software make sure this file is available on you system or reinstall the application');
|
|
raise Exception.Create('Cannot load '+SSL_C_LIB+#10+'To use this software make sure this file is available on you system or reinstall the application');
|
|
end;
|
|
end;
|
|
TCrypto.InitCrypto;
|
|
TCrypto.InitCrypto;
|
|
- FWalletKeys.WalletFileName := TNode.GetPascalCoinDataFolder+PathDelim+'WalletKeys.dat';
|
|
|
|
|
|
+ FWalletKeys.WalletFileName := GetDataFolder+PathDelim+'WalletKeys.dat';
|
|
// Creating Node:
|
|
// Creating Node:
|
|
FNode := TNode.Node;
|
|
FNode := TNode.Node;
|
|
{$IFDEF TESTNET}
|
|
{$IFDEF TESTNET}
|
|
@@ -249,7 +261,7 @@ begin
|
|
Try
|
|
Try
|
|
// Check Database
|
|
// Check Database
|
|
FNode.Bank.StorageClass := TFileStorage;
|
|
FNode.Bank.StorageClass := TFileStorage;
|
|
- TFileStorage(FNode.Bank.Storage).DatabaseFolder := TNode.GetPascalCoinDataFolder+PathDelim+'Data';
|
|
|
|
|
|
+ TFileStorage(FNode.Bank.Storage).DatabaseFolder := GetDataFolder+PathDelim+'Data';
|
|
TFileStorage(FNode.Bank.Storage).LowMemoryUsage := FIniFile.ReadBool(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_LOWMEMORY,False);
|
|
TFileStorage(FNode.Bank.Storage).LowMemoryUsage := FIniFile.ReadBool(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_LOWMEMORY,False);
|
|
// By default daemon will not download checkpoint except if specified on INI file
|
|
// By default daemon will not download checkpoint except if specified on INI file
|
|
TNetData.NetData.MinFutureBlocksToDownloadNewSafebox := FIniFile.ReadInteger(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_MINPENDINGBLOCKSTODOWNLOADCHECKPOINT,0);
|
|
TNetData.NetData.MinFutureBlocksToDownloadNewSafebox := FIniFile.ReadInteger(CT_INI_SECTION_GLOBAL,CT_INI_IDENT_MINPENDINGBLOCKSTODOWNLOADCHECKPOINT,0);
|
|
@@ -268,7 +280,7 @@ begin
|
|
Try
|
|
Try
|
|
Repeat
|
|
Repeat
|
|
Sleep(100);
|
|
Sleep(100);
|
|
- Until Terminated;
|
|
|
|
|
|
+ Until (Terminated) or (Application.Terminated);
|
|
finally
|
|
finally
|
|
FreeAndNil(FMinerServer);
|
|
FreeAndNil(FMinerServer);
|
|
end;
|
|
end;
|
|
@@ -380,30 +392,17 @@ end;
|
|
|
|
|
|
{ TPCDaemonMapper }
|
|
{ TPCDaemonMapper }
|
|
|
|
|
|
-procedure TPCDaemonMapper.OnPascalCoinInThreadLog(logtype: TLogType;
|
|
|
|
- Time: TDateTime; AThreadID: TThreadID; const sender, logtext: String);
|
|
|
|
-Var s : AnsiString;
|
|
|
|
-begin
|
|
|
|
-// If Not SameText(sender,TPCDaemonThread.ClassName) then exit;
|
|
|
|
- If logtype in [lterror,ltinfo] then begin
|
|
|
|
- if AThreadID=MainThreadID then s := ' MAIN:' else s:=' TID:';
|
|
|
|
- WriteLn(formatDateTime('dd/mm/yyyy hh:nn:ss.zzz',Time)+s+IntToHex(PtrInt(AThreadID),8)+' ['+CT_LogType[Logtype]+'] <'+sender+'> '+logtext);
|
|
|
|
- end;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
procedure TPCDaemonMapper.DoOnCreate;
|
|
procedure TPCDaemonMapper.DoOnCreate;
|
|
Var D : TDaemonDef;
|
|
Var D : TDaemonDef;
|
|
begin
|
|
begin
|
|
inherited DoOnCreate;
|
|
inherited DoOnCreate;
|
|
- WriteLn('');
|
|
|
|
- WriteLn(formatDateTime('dd/mm/yyyy hh:nn:ss.zzz',now)+' Starting PascalCoin server');
|
|
|
|
FLog := TLog.Create(Nil);
|
|
FLog := TLog.Create(Nil);
|
|
- FLog.OnInThreadNewLog:=@OnPascalCoinInThreadLog;
|
|
|
|
_FLog := FLog;
|
|
_FLog := FLog;
|
|
D:=DaemonDefs.Add as TDaemonDef;
|
|
D:=DaemonDefs.Add as TDaemonDef;
|
|
- D.DisplayName:='Pascal Coin Daemon';
|
|
|
|
|
|
+ D.DisplayName:='PascalCoin Daemon';
|
|
D.Name:='PascalCoinDaemon';
|
|
D.Name:='PascalCoinDaemon';
|
|
D.DaemonClassName:='TPCDaemon';
|
|
D.DaemonClassName:='TPCDaemon';
|
|
|
|
+ D.Options:=[doAllowStop];
|
|
D.WinBindings.ServiceType:=stWin32;
|
|
D.WinBindings.ServiceType:=stWin32;
|
|
end;
|
|
end;
|
|
|
|
|