Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract mem disabled fixes #67

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions CreatePascalCoinRepository.sh
@@ -0,0 +1,39 @@
echo Skybuck Flying here !
echo
echo Welcome, this batchfile will create a usuable PascalCoin repository for you.
echo
echo Step 1 clone your fork, this must be editted by you
git clone https://github.com/SkybuckFlying/PascalCoin.git

echo Step 2 change to the PascalCoin folder
cd PascalCoin

echo Step 3 add remote to PascalCoinDev
git remote add PascalCoinDev https://github.com/PascalCoinDev/PascalCoin.git

echo Step 4 add remote to PascalCoin
git remote add PascalCoin https://github.com/PascalCoin/PascalCoin.git

echo Step 5 fetch PascalCoinDev repository
git fetch PascalCoinDev

echo Step 6 fetch PascalCoin repository
git fetch PascalCoin

echo Step 7 create local branch for PascalCoinDev/master
git checkout PascalCoinDev/master -b PascalCoinDevMaster

echo Step 8 create local branch for PascalCoin/master
git checkout PascalCoin/master -b PascalCoinMaster

echo Step 9 configure line endings for Microsoft Windows Operating Systems
echo Step 9 (convert CRLF to LF on commit) and (LF to CRLF on checkouts)
git config --global core.autocrlf true








4 changes: 2 additions & 2 deletions src/config.inc
Expand Up @@ -65,11 +65,11 @@
{$DEFINE ASSUME_VALID_POW_OLD_PROTOCOLS}

// Activate ABSTRACTMEM library. Will use a virtual memory caching mechanism for efficient usage without high RAM requirements
{$DEFINE USE_ABSTRACTMEM}
{.$DEFINE USE_ABSTRACTMEM}

// Activate GNUGETTEXT library
{$DEFINE USE_GNUGETTEXT}

// Activate usage of TPCTemporalFileStream instead of TBytes in order to minimize mem usage
// This also fixes issue #207 High memory usage on FreePascal compiler
{.$DEFINE USE_BIGBLOCKS_MEM_ON_DISK}
Expand Down
11 changes: 7 additions & 4 deletions src/core/UBlockChain.pas
Expand Up @@ -541,6 +541,7 @@ TMultiOpData = record

TPCBank = Class(TComponent)
private
FLowMemoryUsage: Boolean;
FStorage : TStorage;
FSafeBox: TPCSafeBox;
FLastBlockCache : TPCOperationsComp;
Expand Down Expand Up @@ -585,6 +586,7 @@ TMultiOpData = record
Function LoadBankFileInfo(Const AFilename : String; var ASafeBoxHeader : TPCSafeBoxHeader) : Boolean;
Property Orphan : TOrphan read FOrphan write FOrphan;
Function SaveBank(forceSave : Boolean) : Boolean;
property LowMemoryUsage : Boolean read FLowMemoryUsage write FLowMemoryUsage;
End;

Const
Expand Down Expand Up @@ -1104,16 +1106,16 @@ function TPCBank.DoSaveBank: Boolean;
{$IFDEF USE_ABSTRACTMEM}
SafeBox.SaveCheckpointing(LBankfilename);
{$ELSE}
fs := TFileStream.Create(bankfilename,fmCreate);
fs := TFileStream.Create(LBankfilename,fmCreate);
try
fs.Size := 0;
fs.Position:=0;
if LowMemoryUsage then begin
Bank.SafeBox.SaveSafeBoxToAStream(fs,0,Bank.SafeBox.BlocksCount-1);
if FLowMemoryUsage then begin
SafeBox.SaveSafeBoxToAStream(fs,0,SafeBox.BlocksCount-1);
end else begin
ms := TMemoryStream.Create;
try
Bank.SafeBox.SaveSafeBoxToAStream(ms,0,Bank.SafeBox.BlocksCount-1);
SafeBox.SaveSafeBoxToAStream(ms,0,SafeBox.BlocksCount-1);
ms.Position := 0;
fs.CopyFrom(ms,0);
finally
Expand All @@ -1123,6 +1125,7 @@ function TPCBank.DoSaveBank: Boolean;
finally
fs.Free;
end;

{$ENDIF}
TLog.NewLog(ltInfo,ClassName,Format('Saving Safebox blocks:%d file:%s in %.2n seconds',[BlocksCount,LBankfilename,TPlatform.GetElapsedMilliseconds(LTC)/1000]));
// Save a copy each 10000 blocks (aprox 1 month) only when not an orphan
Expand Down
9 changes: 6 additions & 3 deletions src/core/UNetProtocol.pas
Expand Up @@ -3196,7 +3196,9 @@ procedure TNetConnection.DoProcess_GetSafeBox_Request(HeaderData: TNetHeaderData
FreeAndNil(Labstracmem);
end;
{$ELSE}
sbStream := TNode.Node.Bank.Storage.OpenSafeBoxCheckpoint(_blockcount);
// sbStream := TNode.Node.Bank.Storage.OpenSafeBoxCheckpoint(_blockcount);
// Skybuck: experimental fix;
sbStream := TNode.Node.Bank.OpenSafeBoxCheckpoint(_blockcount);
try
If Not Assigned(sbStream) then begin
SendError(ntp_response,HeaderData.operation,CT_NetError_SafeboxNotFound,HeaderData.request_id,Format('Safebox stream file for block %d not found',[_blockcount]));
Expand Down Expand Up @@ -3398,7 +3400,8 @@ procedure TNetConnection.DoProcess_GetPubkeyAccounts_Request(HeaderData: TNetHea
pubKey : TAccountKey;
sbakl : TSafeboxPubKeysAndAccounts;
ocl : TAccountsNumbersList;
LAccountsList : TList<Int64>;

LAccountsList : TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>;
begin
{
This call is used to obtain Accounts used by a Public key
Expand Down Expand Up @@ -3445,7 +3448,7 @@ procedure TNetConnection.DoProcess_GetPubkeyAccounts_Request(HeaderData: TNetHea
if Assigned(sbakl) then begin
ocl := sbakl.GetAccountsUsingThisKey(pubKey);
if Assigned(ocl) then begin
LAccountsList := TList<Int64>.Create;
LAccountsList := TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>.Create;
try
ocl.FillList(start,max,LAccountsList);
for i := 0 to LaccountsList.Count-1 do begin
Expand Down
3 changes: 2 additions & 1 deletion src/core/UNode.pas
Expand Up @@ -796,7 +796,8 @@ function TNode.TryFindPublicSaleAccount(AMaximumPrice: Int64; APreventRaceCondit
// Finds an account at or below argument purchase price (or returns false)
// APreventRaceCondition: When True will return a random account in valid range price
// Limitations: Account must be >0
var LtempAccNumber : Int64;
var
LtempAccNumber : {$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF};
LLastValidAccount, LCurrAccount : TAccount;
LContinueSearching : Boolean;
begin
Expand Down
20 changes: 10 additions & 10 deletions src/core/UPCAccountsOrdenations.pas
Expand Up @@ -43,9 +43,9 @@ interface
FCallReturnAccount : TCallReturnAccount;
FSearching_AccountNumber : Int64;
FSearching_UpdatedBlock : Integer;
function DoCompareData(const ALeftData, ARightData: TAbstractMemPosition): Integer; override;
function DoCompareData(const ALeftData, ARightData: {$IFDEF USE_ABSTRACTMEM}TAbstractMemPosition{$ELSE}integer{$ENDIF}): Integer; override;
public
function NodeDataToString(const AData : TAbstractMemPosition) : String; override;
function NodeDataToString(const AData : {$IFDEF USE_ABSTRACTMEM}TAbstractMemPosition{$ELSE}integer{$ENDIF}) : String; override;
End;
private
var
Expand All @@ -67,9 +67,9 @@ interface
FCallReturnAccount : TCallReturnAccount;
FSearching_AccountNumber : Integer;
FSearching_AccountInfo : TAccountInfo;
function DoCompareData(const ALeftData, ARightData: TAbstractMemPosition): Integer; override;
function DoCompareData(const ALeftData, ARightData: {$IFDEF USE_ABSTRACTMEM}TAbstractMemPosition{$ELSE}integer{$ENDIF}): Integer; override;
public
function NodeDataToString(const AData : TAbstractMemPosition) : String; override;
function NodeDataToString(const AData : {$IFDEF USE_ABSTRACTMEM}TAbstractMemPosition{$ELSE}integer{$ENDIF}) : String; override;
function UpdateAccountBySalePrice(const AAccountNumber : Integer; const AOldAccountInfo, ANewAccountInfo : TAccountInfo) : Boolean;
constructor Create({$IFDEF USE_ABSTRACTMEM}AAbstractMem : TAbstractMem; const AInitialZone: TAMZone; {$ENDIF}ACallReturnAccount : TCallReturnAccount);
End;
Expand Down Expand Up @@ -105,7 +105,7 @@ destructor TAccountsOrderedByUpdatedBlock.Destroy;
end;

function TAccountsOrderedByUpdatedBlock.First(var AAccountNumber : Integer) : Boolean;
var i : Int64;
var i : {$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF};
begin
FBTree.Lock;
Try
Expand All @@ -119,7 +119,7 @@ function TAccountsOrderedByUpdatedBlock.First(var AAccountNumber : Integer) : Bo
end;

function TAccountsOrderedByUpdatedBlock.Next(var AAccountNumber : Integer): Boolean;
var i : Int64;
var i : {$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF};
begin
FBTree.Lock;
Try
Expand Down Expand Up @@ -156,7 +156,7 @@ function TAccountsOrderedByUpdatedBlock.Update(const AAccountNumber, AOldUpdated
{ TAccountsOrderedByUpdatedBlock.TAccounstByUpdatedBlockBTree }

function TAccountsOrderedByUpdatedBlock.TAccounstByUpdatedBlockBTree.DoCompareData(
const ALeftData, ARightData: TAbstractMemPosition): Integer;
const ALeftData, ARightData: {$IFDEF USE_ABSTRACTMEM}TAbstractMemPosition{$ELSE}integer{$ENDIF}): Integer;
var LLeftAccount, LRightAccount : TAccount;
begin
if (ALeftData = ARightData) then Exit(0);
Expand All @@ -172,7 +172,7 @@ function TAccountsOrderedByUpdatedBlock.TAccounstByUpdatedBlockBTree.DoCompareDa
end;

function TAccountsOrderedByUpdatedBlock.TAccounstByUpdatedBlockBTree.NodeDataToString(
const AData: TAbstractMemPosition): String;
const AData: {$IFDEF USE_ABSTRACTMEM}TAbstractMemPosition{$ELSE}integer{$ENDIF}): String;
var LAccount : TAccount;
begin
if FCallReturnAccount(AData,LAccount) then begin
Expand All @@ -196,7 +196,7 @@ constructor TAccountsOrderedBySalePrice.Create({$IFDEF USE_ABSTRACTMEM}AAbstract
end;

function TAccountsOrderedBySalePrice.DoCompareData(const ALeftData,
ARightData: TAbstractMemPosition): Integer;
ARightData: {$IFDEF USE_ABSTRACTMEM}TAbstractMemPosition{$ELSE}integer{$ENDIF}): Integer;
var LLeftAccount, LRightAccount : TAccount;
LopResult : Int64;
begin
Expand All @@ -215,7 +215,7 @@ function TAccountsOrderedBySalePrice.DoCompareData(const ALeftData,
end;

function TAccountsOrderedBySalePrice.NodeDataToString(
const AData: TAbstractMemPosition): String;
const AData: {$IFDEF USE_ABSTRACTMEM}TAbstractMemPosition{$ELSE}integer{$ENDIF}): String;
var LAccount : TAccount;
begin
if FCallReturnAccount(AData,LAccount) then begin
Expand Down
4 changes: 2 additions & 2 deletions src/core/UPCRPCFindAccounts.pas
Expand Up @@ -152,7 +152,7 @@ class function TRPCFindAccounts.FindAccounts(const ASender: TRPCProcess;
LAccPubKey : TAccountKey;
LOutput : TPCJSONArray;
LStartsWith : TOrderedRawList;
LAccountsList : TList<Int64>;
LAccountsList : TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>;
begin
// Get Parameters
Result := False;
Expand Down Expand Up @@ -279,7 +279,7 @@ class function TRPCFindAccounts.FindAccounts(const ASender: TRPCProcess;
end else begin
// Search by type-forSale-balance
if (LSearchByPubkey) then begin
LAccountsList := TList<Int64>.Create;
LAccountsList := TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>.Create;
try
LAccountsNumbersList.FillList(LStart,LEnd-LStart+1,LAccountsList);
for i := 0 to LAccountsList.Count-1 do begin
Expand Down
10 changes: 5 additions & 5 deletions src/core/URPC.pas
Expand Up @@ -3167,7 +3167,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
jsonarr : TPCJSONArray;
jso : TPCJSONObject;
LRPCProcessMethod : TRPCProcessMethod;
LAccountsList : TList<Int64>;
LAccountsList : TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>;
begin
_ro := Nil;
_ra := Nil;
Expand Down Expand Up @@ -3229,7 +3229,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
Lanl := _RPCServer.WalletKeys.AccountsKeyList.AccountKeyList[i];
k := params.AsInteger('max',100);
l := params.AsInteger('start',0);
LAccountsList := TList<Int64>.Create;
LAccountsList := TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>.Create;
Try
Lanl.FillList(l,k,LAccountsList);
for j := 0 to LAccountsList.Count - 1 do begin
Expand All @@ -3246,7 +3246,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
c := 0;
for i:=0 to _RPCServer.WalletKeys.AccountsKeyList.Count-1 do begin
Lanl := _RPCServer.WalletKeys.AccountsKeyList.AccountKeyList[i];
LAccountsList := TList<Int64>.Create;
LAccountsList := TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>.Create;
Try
Lanl.FillList(0,Lanl.Count,LAccountsList);
for j := 0 to LAccountsList.Count - 1 do begin
Expand Down Expand Up @@ -3316,7 +3316,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
Lanl := _RPCServer.WalletKeys.AccountsKeyList.AccountKeyList[i];
account.balance := 0;

LAccountsList := TList<Int64>.Create;
LAccountsList := TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>.Create;
Try
Lanl.FillList(0,Lanl.Count,LAccountsList);
for j := 0 to LAccountsList.Count - 1 do begin
Expand All @@ -3335,7 +3335,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
for i:=0 to _RPCServer.WalletKeys.AccountsKeyList.Count-1 do begin
Lanl := _RPCServer.WalletKeys.AccountsKeyList.AccountKeyList[i];

LAccountsList := TList<Int64>.Create;
LAccountsList := TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>.Create;
Try
Lanl.FillList(0,Lanl.Count,LAccountsList);
for j := 0 to LAccountsList.Count - 1 do begin
Expand Down
4 changes: 2 additions & 2 deletions src/gui-classic/UGridUtils.pas
Expand Up @@ -298,7 +298,7 @@ procedure TAccountsGridUpdateThread.BCExecute;
LApplyfilter : Boolean;
LAccount : TAccount;
LNode : TNode;
LAccountsList : TList<Int64>;
LAccountsList : TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>;
begin
LApplyfilter := ((FAccountsGridFilter.MinBalance>0) Or ((FAccountsGridFilter.MaxBalance>=0) And (FAccountsGridFilter.MaxBalance<CT_MaxWalletAmount)));
FBalance := 0;
Expand All @@ -321,7 +321,7 @@ procedure TAccountsGridUpdateThread.BCExecute;
LAccountsNumbersList := FAccountsGridFilter.OrderedAccountsKeyList.AccountKeyList[i];
if Assigned(LAccountsNumbersList) then begin

LAccountsList := TList<Int64>.Create;
LAccountsList := TList<{$IFDEF USE_ABSTRACTMEM}Int64{$ELSE}integer{$ENDIF}>.Create;
Try
LAccountsNumbersList.FillList(j_min,50000,LAccountsList);
for j := 0 to LAccountsList.Count - 1 do begin
Expand Down