async void Get(long height, long spacing, string ipEndPoint) { GetFunCount++; try { record.Add(height); // Dictionary <long, string> blockChains = new Dictionary <long, string>(); bool error = false; var q2p_Sync_Height = new Q2P_Sync_Height(); q2p_Sync_Height.spacing = spacing; q2p_Sync_Height.height = height; var reply = await cons.QuerySync_Height(q2p_Sync_Height, ipEndPoint, 30); if (reply == null) { ipEndPoint = nodeManager.GetRandomNode().ipEndPoint; reply = await cons.QuerySync_Height(q2p_Sync_Height, ipEndPoint, 30); } if (reply != null && !string.IsNullOrEmpty(reply.blockChains)) { Log.Info($"SyncHeightFast.Get AddBlock {height} {ipEndPoint}"); blockChains = JsonHelper.FromJson <Dictionary <long, string> >(reply.blockChains); do { for (int kk = 0; kk < reply.blocks.Count; kk++) { var blk = JsonHelper.FromJson <Block>(reply.blocks[kk]); if (!blockMgr.AddBlock(blk)) { error = true; break; } } if (!error && reply.height != -1) { q2p_Sync_Height.height = reply.height; q2p_Sync_Height.spacing = Math.Max(1, spacing - (reply.height - height)); reply = await cons.QuerySync_Height(q2p_Sync_Height, ipEndPoint, 30); } }while (!error && reply != null && reply.height != -1); } else { Log.Info($"SyncHeightFast.Get Remove {height} {ipEndPoint}"); record.Remove(height); } } catch (Exception) { } GetFunCount--; }