public DBFileInfo RequestHightestDBInfo() { LogHelper.WriteMethodLog(true); XXPSocketsModel sendMod = new XXPSocketsModel(); sendMod.Type = XXPCoinMsgType.DBfile; sendMod.Value = DBRequestType.RequestDBInfo; List <DBFileInfo> lstDBInfo = new List <DBFileInfo>(); foreach (var item in this.dicAddressesPool) { XXPSocketsModel RetMod = this.XXPSendMessage(item.Key, sendMod); if (!string.IsNullOrEmpty(RetMod.Value)) { DBFileInfo dbInfo = JsonHelper.Deserialize <DBFileInfo>(RetMod.Value); dbInfo.IP = RetMod.IpAddress; lstDBInfo.Add(dbInfo); } } var ss = lstDBInfo.Max(x => x.LastBlockHeight); DBFileInfo hightestDBInfo = lstDBInfo.FirstOrDefault(x => x.LastBlockHeight == ss); LogHelper.WriteInfoLog("HightestDBInfo: " + JsonHelper.Serializer <DBFileInfo>(hightestDBInfo)); return(hightestDBInfo); }
private string GetDBfileInfo() { try { LogHelper.WriteMethodLog(true); string tempzip = Path.Combine(AppSettings.XXPTempFolder, ConstHelper.BC_DBZipName); if (File.Exists(tempzip)) { FileIOHelper.DeleteFile(tempzip); } ZipHelper.Zip(AppSettings.XXPDBFolder, tempzip); FileInfo tempzipInfo = new FileInfo(tempzip); LeveldbOperator.OpenDB(AppSettings.XXPDBFolder); string strLastblock = LeveldbOperator.GetValue(ConstHelper.BC_LastKey); Block block = JsonHelper.Deserialize <Block>(strLastblock); LeveldbOperator.CloseDB(); DBFileInfo dbinfo = new DBFileInfo(tempzipInfo.Length, block.Header.Height); return(JsonHelper.Serializer <DBFileInfo>(dbinfo));; } catch (Exception ex) { LogHelper.WriteErrorLog(ex.Message); return(string.Empty); } finally { LogHelper.WriteMethodLog(false); } }