Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Commit

Permalink
filtering MNs
Browse files Browse the repository at this point in the history
  • Loading branch information
NosoDevTeam committed Aug 31, 2024
1 parent c689fb8 commit 0f98ce3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lastrelease.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.2Da2 0.4.2Da2 x {LastOfficial} {LastBeta} {TestNet}
0.4.3Aa1 0.4.2Da2 x {LastOfficial} {LastBeta} {TestNet}
1 change: 1 addition & 0 deletions mpblock.pas
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ implementation
FillNodeList;
ClearMNsChecks();
ClearMNsList();
ClearReceivedMNs();
if numero >= MNBlockStart then
begin
SetLength(MNsAddressess,0);
Expand Down
2 changes: 1 addition & 1 deletion mpred.pas
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ function CerrarClientes(ServerToo:Boolean=True):string;
end;

// *** Request reported MNs
if ( (StrToIntDef(GetConsensus(9),0)>GetMNsListLength) and (LastTimeMNsRequested+5<UTCTime)
if ( (StrToIntDef(GetConsensus(9),0)>GetMNsListLength) and (LastTimeMNsRequested+15<UTCTime)
and (LengthWaitingMNs = 0) and (BlockAge>30) and (IsAllSynced=0) ) then
begin
if GetValidSlotForSeed(ValidSlot) then
Expand Down
51 changes: 51 additions & 0 deletions nosomasternodes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ TThreadMNVerificator = class(TThread)
Procedure SetMNsHash();
Function GetMNsHash():String;

Function LengthReceivedMNs():Integer;
Procedure ClearReceivedMNs();
Function IsMNIPReceived(DataSource:String):boolean;

Function LengthWaitingMNs():Integer;
Procedure AddWaitingMNs(Linea:String);
Function GetWaitingMNs():String;
Expand Down Expand Up @@ -132,6 +136,9 @@ TThreadMNVerificator = class(TThread)
ArrWaitMNs : array of String;
CSWaitingMNs : TRTLCriticalSection;

ArrReceivedMNs : array of String;
CSReceivedMNs : TRTLCriticalSection;

IMPLEMENTATION

Procedure SetMasternodesFilename(LText:String);
Expand Down Expand Up @@ -711,6 +718,46 @@ function IsMyMNListed(LocalIP:String):boolean;

{$ENDREGION MNs hash}

{$REGION Received Masternodes}

Function LengthReceivedMNs():Integer;
Begin
EnterCriticalSection(CSReceivedMNs);
result := Length(ArrReceivedMNs);
LeaveCriticalSection(CSReceivedMNs);
End;

Procedure ClearReceivedMNs();
Begin
EnterCriticalSection(CSReceivedMNs);
setlength(ArrReceivedMNs,0);
LeaveCriticalSection(CSReceivedMNs);
End;

Function IsMNIPReceived(DataSource:String):boolean;
var
counter : integer;
Begin
Result := false;
DataSource := Parameter(DataSource,5);
EnterCriticalSection(CSReceivedMNs);
for counter := 0 to length(ArrReceivedMNs)-1 do
begin
if ArrReceivedMNs[counter] = DataSource then
begin
Result := true;
Break
end;
end;
if not result then
begin
Insert(DataSource,ArrReceivedMNs,LEngth(ArrReceivedMNs))
end;
LeaveCriticalSection(CSReceivedMNs);
End;

{$ENDREGION Received Masternodes}

{$REGION Waiting Masternodes}

Function LengthWaitingMNs():Integer;
Expand All @@ -722,6 +769,7 @@ function IsMyMNListed(LocalIP:String):boolean;

Procedure AddWaitingMNs(Linea:String);
Begin
if IsMNIPReceived(linea) then exit;;
EnterCriticalSection(CSWaitingMNs);
Insert(Linea,ArrWaitMNs,Length(ArrWaitMNs));
LeaveCriticalSection(CSWaitingMNs);
Expand Down Expand Up @@ -872,6 +920,7 @@ function IsMyMNListed(LocalIP:String):boolean;
SetLength(ArrMNChecks,0);
SetLength(ArrayMNsData,0);
Setlength(ArrWaitMNs,0);
Setlength(ArrReceivedMNs,0);
InitCriticalSection(CSMNsIPProc);
InitCriticalSection(CSMNsList);
InitCriticalSection(CSVerNodes);
Expand All @@ -882,6 +931,7 @@ function IsMyMNListed(LocalIP:String):boolean;
InitCriticalSection(CSWaitingMNs);
InitCriticalSection(CSMN_FileText);
InitCriticalSection(CSMNsChecks);
InitCriticalSection(CSReceivedMNs);


FINALIZATION
Expand All @@ -895,6 +945,7 @@ function IsMyMNListed(LocalIP:String):boolean;
DoneCriticalSection(CSWaitingMNs);
DoneCriticalSection(CSMN_FileText);
DoneCriticalSection(CSMNsChecks);
DoneCriticalSection(CSReceivedMNs);


END. // End unit
Expand Down

0 comments on commit 0f98ce3

Please sign in to comment.