예제 #1
0
        public void AddBloq(T data)
        {
            if (EqualityComparer <T> .Default.Equals(data, default(T)))
            {
                throw new ArgumentException("The data you are trying to add is the default for the type. Use actual data for the bloq", nameof(data));
            }

            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            Bloq <T> bloqToAdd = new Bloq <T>(this.Length, 0, DateTime.UtcNow, data, this.chain[this.Length - 1].Hash);

            bloqToAdd.Mine(this.Difficulty);

            this.chain.Add(bloqToAdd);
        }
예제 #2
0
        public BloqChain(int difficulty)
        {
            if (difficulty < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(difficulty), "Difficulty must be zero a positive number");
            }

            this.Difficulty = difficulty;

            var genesisBloq = new Bloq <T>();

            genesisBloq.Mine(this.Difficulty);

            this.chain = new List <Bloq <T> >
            {
                genesisBloq
            };
        }