Skip to content

Commit a29c1cf

Browse files
committed
Fixed: block downloading
1 parent b169104 commit a29c1cf

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

Units/PascalCoin/UBlockChain.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ function TPCBank.AddNewBlockChainBlock(Operations: TPCOperationsComp; var newBlo
468468
maxAllowedTimestamp := maxAllowedTimestamp + CT_MaxSecondsFutureBlockTime;
469469
if Operations.OperationBlock.timestamp > maxAllowedTimestamp then begin
470470
errors := 'Invalid timestamp (Future time '+Inttostr(Operations.OperationBlock.timestamp)+'-'+inttostr(UnivDateTimeToUnix(DateTime2UnivDateTime(now)))+'='+
471-
inttostr(Operations.OperationBlock.timestamp-UnivDateTimeToUnix(DateTime2UnivDateTime(now)))+' > '+inttostr(CT_MaxSecondsDifferenceOfNetworkNodes)+')';
471+
inttostr(Operations.OperationBlock.timestamp-UnivDateTimeToUnix(DateTime2UnivDateTime(now)))+' > '+inttostr(CT_MaxSecondsFutureBlockTime)+')';
472472
exit;
473473
end;
474474
end else begin

Units/PascalCoin/ULog.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ procedure TLog.NotifyNewLog(logtype: TLogType; Const sender, logtext: String);
180180
New(P);
181181
P^.Logtype := logtype;
182182
P^.Time := now;
183-
P^.ThreadID :=TThread.CurrentThread.ThreadID;
183+
P^.ThreadID := GetCurrentThreadId;
184184
P^.Sender := sender;
185185
P^.Logtext := logtext;
186186
FLogDataList.Add(P);

Units/PascalCoin/UNetProtocol.pas

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,16 +2037,15 @@ procedure TNetConnection.DoProcess_GetBlocks_Response(HeaderData: TNetHeaderData
20372037
end else begin
20382038
// Receiving an unexpected operationblock
20392039
TLog.NewLog(lterror,classname,'Received a distinct block, finalizing: '+TPCOperationsComp.OperationBlockToText(op.OperationBlock)+' (My block: '+TPCOperationsComp.OperationBlockToText(TNode.Node.Bank.LastOperationBlock)+')' );
2040-
FIsDownloadingBlocks := false;
20412040
exit;
20422041
end;
20432042
end;
2044-
FIsDownloadingBlocks := false;
20452043
if ((opcount>0) And (FRemoteOperationBlock.block>=TNode.Node.Bank.BlocksCount)) then begin
20462044
Send_GetBlocks(TNode.Node.Bank.BlocksCount,1000,i);
20472045
end;
20482046
TNode.Node.NotifyBlocksChanged;
20492047
Finally
2048+
FIsDownloadingBlocks := false;
20502049
op.Free;
20512050
End;
20522051
Finally
@@ -3174,13 +3173,13 @@ procedure TThreadGetNewBlockChainFromClient.Execute;
31743173
candidates.Add(nc);
31753174
end;
31763175
end;
3176+
TLog.NewLog(ltdebug, Classname, Format('Candidates: %d Downloading: %d', [candidates.Count, downloading]));
3177+
31773178
if downloading or (candidates.Count = 0) then
31783179
begin
31793180
continue;
31803181
end;
31813182

3182-
TLog.NewLog(ltdebug, Classname, Format('Candidates: %d', [candidates.Count]));
3183-
31843183
connection := TNetConnection(candidates[Random(candidates.Count)]);
31853184
if not connection.RefAdd then
31863185
begin

0 commit comments

Comments
 (0)