anchor.diff:    Result := (BlocksCount MOD CT_BankToDiskEveryNBlocks)=0;
   end;
   
  -procedure TPCSafeBox.SaveSafeBoxBlockToAStream(Stream: TStream; nBlock: Cardinal);
  +procedure TPCSafeBox.SaveSafeBoxBlockToAStream(DestStream: TStream; nBlock: Cardinal);
   var b : TBlockAccount;
     iacc : integer;
  +  Stream : TStream;
   begin
     b := Block(nblock);
  -  TAccountComp.SaveTOperationBlockToStream(Stream,b.blockchainInfo);
  -  for iacc := Low(b.accounts) to High(b.accounts) do begin
  -    Stream.Write(b.accounts[iacc].account,Sizeof(b.accounts[iacc].account));
  -    TStreamOp.WriteAnsiString(Stream,TAccountComp.AccountInfo2RawString(b.accounts[iacc].accountInfo));
  -    Stream.Write(b.accounts[iacc].balance,Sizeof(b.accounts[iacc].balance));
  -    Stream.Write(b.accounts[iacc].updated_block,Sizeof(b.accounts[iacc].updated_block));
  -    Stream.Write(b.accounts[iacc].n_operation,Sizeof(b.accounts[iacc].n_operation));
  -    If FCurrentProtocol>=CT_PROTOCOL_2 then begin
  -      TStreamOp.WriteAnsiString(Stream,b.accounts[iacc].name);
  -      Stream.Write(b.accounts[iacc].account_type,SizeOf(b.accounts[iacc].account_type));
  -    end;
  -    Stream.Write(b.accounts[iacc].previous_updated_block,Sizeof(b.accounts[iacc].previous_updated_block));
  -  end;
  -  TStreamOp.WriteAnsiString(Stream,b.block_hash);
  -  Stream.Write(b.accumulatedWork,Sizeof(b.accumulatedWork));
  +  if DestStream is TMemoryStream then Stream := DestStream
  +  else begin
  +    Stream := TMemoryStream.Create;
  +  end;
  +  try
  +    TAccountComp.SaveTOperationBlockToStream(Stream,b.blockchainInfo);
  +    for iacc := Low(b.accounts) to High(b.accounts) do begin
  +      Stream.Write(b.accounts[iacc].account,Sizeof(b.accounts[iacc].account));
  +      TStreamOp.WriteAnsiString(Stream,TAccountComp.AccountInfo2RawString(b.accounts[iacc].accountInfo));
  +      Stream.Write(b.accounts[iacc].balance,Sizeof(b.accounts[iacc].balance));
  +      Stream.Write(b.accounts[iacc].updated_block,Sizeof(b.accounts[iacc].updated_block));
  +      Stream.Write(b.accounts[iacc].n_operation,Sizeof(b.accounts[iacc].n_operation));
  +      If FCurrentProtocol>=CT_PROTOCOL_2 then begin
  +        TStreamOp.WriteAnsiString(Stream,b.accounts[iacc].name);
  +        Stream.Write(b.accounts[iacc].account_type,SizeOf(b.accounts[iacc].account_type));
  +      end;
  +      Stream.Write(b.accounts[iacc].previous_updated_block,Sizeof(b.accounts[iacc].previous_updated_block));
  +    end;
  +    TStreamOp.WriteAnsiString(Stream,b.block_hash);
  +    Stream.Write(b.accumulatedWork,Sizeof(b.accumulatedWork));
  +  finally
  +    if (Stream<>DestStream) then begin
  +      DestStream.CopyFrom(Stream,0);
  +      Stream.Free;
  +    end;
  +  end;
   end;
   
   procedure TPCSafeBox.SaveSafeBoxToAStream(Stream: TStream; FromBlock, ToBlock : Cardinal);
  
positive.code:   end;
    // Update buffer block hash
    j := (length(blockAccount.block_hash)*(iBlock));  // j in 0,32,64...
    for i := 1 to length(blockAccount.block_hash) do begin  // i in 1..32
      FBufferBlocksHash[i+j] := AnsiChar(blockAccount.block_hash[i]);
    end;
  
    FTotalBalance := FTotalBalance - (Int64(lastbalance)-Int64(newBalance));
    FTotalFee := FTotalFee + (Int64(lastbalance)-Int64(newBalance));
  
negative.code:       end;
        // Build 1.3.0 to increase reading speed:
        FBlockAccountsList.Capacity := sbHeader.blockscount;
        FBufferBlocksHash.SetLength(sbHeader.blocksCount*32);
        errors := 'Corrupted stream';
        for iblock := 0 to sbHeader.blockscount-1 do begin
          if (Assigned(progressNotify)) and ((TPlatform.GetElapsedMilliseconds(tc)>=500)) then begin
  