예제 #1
0
        public IPruningState Merge(IPruningState other)
        {
            if (other is PruningPerformed that)
            {
                return(ObsoleteTime >= that.ObsoleteTime ? this : that);
            }

            return(this);
        }
예제 #2
0
        public IPruningState Merge(IPruningState other)
        {
            var that = other as PruningPerformed;

            if (that != null)
            {
                return(this.ObsoleteTime >= that.ObsoleteTime ? this : that);
            }
            else
            {
                return(this);
            }
        }
예제 #3
0
        /// <inheritdoc/>

        public IPruningState Merge(IPruningState other)
        {
            if (other is PruningPerformed)
            {
                return(other);
            }

            var that = (PruningInitialized)other;

            if (Owner == that.Owner)
            {
                return(new PruningInitialized(Owner, Seen.Union(that.Seen)));
            }
            return(Member.AddressOrdering.Compare(Owner.Address, that.Owner.Address) > 0 ? other : this);
        }
예제 #4
0
        private Proto.Msg.DataEnvelope.Types.PruningEntry PruningToProto(UniqueAddress addr, IPruningState pruning)
        {
            var proto = new Proto.Msg.DataEnvelope.Types.PruningEntry
            {
                RemovedAddress = SerializationSupport.UniqueAddressToProto(addr)
            };

            switch (pruning)
            {
            case PruningPerformed performed:
                proto.Performed    = true;
                proto.ObsoleteTime = performed.ObsoleteTime.Ticks;
                break;

            case PruningInitialized init:
                proto.Performed    = false;
                proto.OwnerAddress = SerializationSupport.UniqueAddressToProto(init.Owner);
                foreach (var address in init.Seen)
                {
                    proto.Seen.Add(SerializationSupport.AddressToProto(address));
                }
                break;
            }

            return(proto);
        }