Beispiel #1
0
        public List <BlockHeaderMsg> GetBlockHeaderMsgByHeights(List <long> heights)
        {
            var blockDac = new BlockDac();
            var txDac    = new TransactionDac();
            var headers  = new List <BlockHeaderMsg>();

            foreach (var height in heights)
            {
                var items = blockDac.SelectByHeight(height);

                foreach (var entity in items)
                {
                    var header = new BlockHeaderMsg();
                    header.Version           = entity.Version;
                    header.Hash              = entity.Hash;
                    header.Height            = entity.Height;
                    header.PreviousBlockHash = entity.PreviousBlockHash;
                    header.Bits              = entity.Bits;
                    header.Nonce             = entity.Nonce;
                    header.Timestamp         = entity.Timestamp;

                    var transactions = txDac.SelectByBlockHash(entity.Hash);
                    header.TotalTransaction = entity.Transactions == null ? 0 : entity.Transactions.Count;

                    headers.Add(header);
                }
            }

            return(headers);
        }
Beispiel #2
0
        public BlockMsg GetBlockMsgByHeight(long height)
        {
            var      blockDac = new BlockDac();
            var      txDac    = new TransactionDac();
            BlockMsg block    = null;

            var items = blockDac.SelectByHeight(height);

            if (items.Count > 0)
            {
                block = this.convertEntityToBlockMsg(items[0]);
            }

            return(block);
        }
Beispiel #3
0
        public List <BlockMsg> GetBlockMsgByHeights(List <long> heights)
        {
            var blockDac  = new BlockDac();
            var txDac     = new TransactionDac();
            var inputDac  = new InputDac();
            var outputDac = new OutputDac();
            var blocks    = new List <BlockMsg>();

            foreach (var height in heights)
            {
                var items = blockDac.SelectByHeight(height);

                foreach (var entity in items)
                {
                    blocks.Add(this.convertEntityToBlockMsg(entity));
                }
            }

            return(blocks);
        }
Beispiel #4
0
        public List <BlockHeaderMsg> GetBlockHeaderMsgByHeights(List <long> heights)
        {
            var blockDac = new BlockDac();
            var txDac    = new TransactionDac();
            var headers  = new List <BlockHeaderMsg>();

            foreach (var height in heights)
            {
                var items = blockDac.SelectByHeight(height);

                foreach (var entity in items)
                {
                    var header = new BlockHeaderMsg();
                    header.Version           = entity.Version;
                    header.Hash              = entity.Hash;
                    header.Height            = entity.Height;
                    header.PreviousBlockHash = entity.PreviousBlockHash;
                    header.Bits              = entity.Bits;
                    header.Nonce             = entity.Nonce;
                    header.Timestamp         = entity.Timestamp;
                    header.GeneratorId       = entity.GeneratorId;
                    //header.GenerationSignature = entity.GenerationSignature;
                    //header.BlockSignature = entity.BlockSignature;
                    //header.CumulativeDifficulty = entity.CumulativeDifficulty;
                    header.PayloadHash    = entity.PayloadHash;
                    header.BlockSignature = entity.BlockSignature;
                    header.BlockSigSize   = entity.BlockSignature.Length;

                    var transactions = txDac.SelectByBlockHash(entity.Hash);
                    header.TotalTransaction = entity.Transactions == null ? 0 : entity.Transactions.Count;

                    headers.Add(header);
                }
            }

            return(headers);
        }