コード例 #1
0
ファイル: QuorumGenerator.cs プロジェクト: mahdiz/mpclib
        public static List<SortedSet<int>> GenerateQuorums(SortedSet<int> parties, int quorumCount, int countPerQuorum, BigInteger seed)
        {
            // ensure that every party will be in a quorum
            Debug.Assert(quorumCount * countPerQuorum >= parties.Count);

            List<SortedSet<int>> quorums = new List<SortedSet<int>>();

            int intSeed = seed.GetHashCode();
            //   Random randGen = new Random(intSeed);
            Random randGen = new Random(3);
            Dictionary<int, int> partyPositions = new Dictionary<int, int>();
            int pos = 0;
            foreach (int party in parties)
                partyPositions[pos++] = party;

            do
            {
                quorums.Clear();
                for (int i = 0; i < quorumCount; i++)
                {
                    quorums.Add(GenerateQuorum(randGen, countPerQuorum, parties.Count, partyPositions));
                }
            } while (!AreAllInQuorum(quorums, parties.Count));

            return quorums;
        }
コード例 #2
0
ファイル: ChainedBlock.cs プロジェクト: holinov/BitSharp
        public ChainedBlock(UInt256 blockHash, UInt256 previousBlockHash, int height, BigInteger totalWork)
        {
            this._blockHash = blockHash;
            this._previousBlockHash = previousBlockHash;
            this._height = height;
            this._totalWork = totalWork;

            this.hashCode = blockHash.GetHashCode() ^ previousBlockHash.GetHashCode() ^ height.GetHashCode() ^ totalWork.GetHashCode();
        }
コード例 #3
0
ファイル: BigIntegerTest.cs プロジェクト: koush/mono
		public void DefaultCtorWorks ()
		{
			var a = new BigInteger ();
			Assert.AreEqual (BigInteger.One, ++a, "#1");

			a = new BigInteger ();
			Assert.AreEqual (BigInteger.MinusOne, --a, "#2");

			a = new BigInteger ();
			Assert.AreEqual (BigInteger.MinusOne, ~a, "#3");

			a = new BigInteger ();
			Assert.AreEqual ("0", a.ToString (), "#4");

			a = new BigInteger ();
			Assert.AreEqual (true, a == a, "#5");

			a = new BigInteger ();
			Assert.AreEqual (false, a < a, "#6");

			a = new BigInteger ();
			Assert.AreEqual (true, a < 10l, "#7");

			a = new BigInteger ();
			Assert.AreEqual (true, a.IsEven, "#8");

			a = new BigInteger ();
			Assert.AreEqual (0, (int)a, "#9");

			a = new BigInteger ();
			Assert.AreEqual (0, (uint)a, "#10");

			a = new BigInteger ();
			Assert.AreEqual (0, (ulong)a, "#11");

			a = new BigInteger ();
			Assert.AreEqual (true, a.Equals (a), "#12");

			a = new BigInteger ();
			Assert.AreEqual (a, BigInteger.Min (a, a), "#13");

			a = new BigInteger ();
			Assert.AreEqual (a, BigInteger.GreatestCommonDivisor (a, a), "#14");

			a = new BigInteger ();
			Assert.AreEqual (BigInteger.Zero.GetHashCode (), a.GetHashCode (), "#15");
		}
コード例 #4
0
ファイル: BigDecimal.cs プロジェクト: tjake/fluentcassandra
 public override int GetHashCode()
 {
     return(_unscaledValue.GetHashCode() ^ _scale.GetHashCode());
 }