Beispiel #1
0
        public ISignedData <T> GetSingedData(int index)
        {
            if (index >= chain.Count)
            {
                return(null);
            }

            return(SignedData <T> .CreateFromBlock(chain[index]));
        }
Beispiel #2
0
        public IEnumerable <ISignedData <T> > GetByTag(string tag)
        {
            var result = new List <ISignedData <T> >();

            if (tags.ContainsKey(tag))
            {
                foreach (var index in tags[tag].Indexes)
                {
                    result.Add(SignedData <T> .CreateFromBlock(GetBlock(index, allowRedirects)));
                }
            }

            return(result);
        }
Beispiel #3
0
        public ISignedData <T> Add(T data, DateTime time, int nonce, params string[] tags)
        {
            var latestBlock = GetLatestBlock();

            var block = Block <T> .Create(latestBlock, data, difficulty, time, nonce);

            block.Mine();
            chain.Add(block);

            foreach (var tag in tags)
            {
                if (this.tags.ContainsKey(tag))
                {
                    this.tags[tag].AddIndex(block.Index);
                }
            }

            return(SignedData <T> .CreateFromBlock(block));
        }
Beispiel #4
0
 public ISignedData <T> this[int index]
 {
     get { return(index < chain.Count ? SignedData <T> .CreateFromBlock(GetBlock(index, allowRedirects)) : null); }
 }