Example #1
0
        void Search_Found(DhtSearch search, DhtAddress source, byte[] data)
        {
            G2Header root = new G2Header(data);

            if (!G2Protocol.ReadPacket(root))
            {
                return;
            }

            UpdateInfo info = UpdateInfo.Decode(root); // verifies signature

            if (info == null)
            {
                return;
            }

            if (Core.Context.SignedUpdate == null || Core.Context.SignedUpdate.SequentialVersion < info.SequentialVersion)
            {
                Core.Context.SignedUpdate = info;
                LookupConfig.WriteUpdateInfo(Core);
            }

            // version less than what we have
            else if (Core.Context.SignedUpdate.SequentialVersion > info.SequentialVersion)
            {
                return;
            }

            // version remote has already loaded
            if (Core.Context.SignedUpdate.Loaded)
            {
                return;
            }

            // same sources will be hit as file download search progresses
            StartDownload(search.TargetID);
        }