예제 #1
0
파일: Quorum.cs 프로젝트: mahdiz/mpclib
        public ulong GetNextTwoProtocolId(Quorum other, bool incrementOther = true)
        {
            if (this == other)
            {
                return(GetNextProtocolId());
            }

            if (!TwoQuorumProtocolIds.ContainsKey(other))
            {
                TwoQuorumProtocolIds[other] = 0;
            }

            // if we are failing this assert, we need to expand the range
            Debug.Assert(TwoQuorumProtocolIds[other] <= ushort.MaxValue);

            ulong retId = ProtocolIdGenerator.TwoQuorumProtocolIdentifier(QuorumNumber, other.QuorumNumber, TwoQuorumProtocolIds[other]);

            TwoQuorumProtocolIds[other]++;

            // increment the id in the other quorum (necessary because a party may be part of both quorums)
            if (incrementOther)
            {
                other.GetNextTwoProtocolId(this, false);
            }

            return(retId);
        }
예제 #2
0
 public override void Teardown()
 {
     base.Teardown();
     if (ProtocolIdGenerator.IsQuorumProtocolIdentifier(ProtocolId))
     {
         Quorums[0].ReleaseId(ProtocolId);
     }
 }
예제 #3
0
파일: Quorum.cs 프로젝트: mahdiz/mpclib
        public ulong GetNextProtocolId()
        {
            Debug.Assert(UsedIds.LongCount() < uint.MaxValue);
            while (UsedIds.Contains(WhichProtocol))
            {
                WhichProtocol++;
            }

            return(ProtocolIdGenerator.QuorumProtocolIdentifier(QuorumNumber, WhichProtocol++));
        }
예제 #4
0
파일: Quorum.cs 프로젝트: mahdiz/mpclib
 public void ReleaseId(ulong id)
 {
     UsedIds.Remove(ProtocolIdGenerator.GetIntraQuorumProtocolNumber(id));
 }