Exemplo n.º 1
0
        public IEnumerable <SyncTransactionInfo> BlockTransactionGetByBlockIndex(long blockIndex)
        {
            SyncBlockInfo blk     = BlockGetByIndex(blockIndex);
            SyncBlockInfo current = BlockGetBlockCount(1).First();

            FilterDefinition <MapTransactionBlock> filter = Builders <MapTransactionBlock> .Filter.Eq(info => info.BlockIndex, blk.BlockIndex);

            var trxs = MapTransactionBlock.Find(filter).ToList();

            return(trxs.Select(s => new SyncTransactionInfo
            {
                BlockIndex = s.BlockIndex,
                BlockHash = blk.BlockHash,
                Timestamp = blk.BlockTime,
                TransactionHash = s.TransactionId,
                Confirmations = current.BlockIndex - s.BlockIndex
            }));
        }
Exemplo n.º 2
0
        public void DeleteBlock(string blockHash)
        {
            SyncBlockInfo block = BlockGetByHash(blockHash);

            // delete the outputs
            FilterDefinition <MapTransactionAddress> addrFilter = Builders <MapTransactionAddress> .Filter.Eq(addr => addr.BlockIndex, block.BlockIndex);

            MapTransactionAddress.DeleteMany(addrFilter);

            // delete the transaction
            FilterDefinition <MapTransactionBlock> transactionFilter = Builders <MapTransactionBlock> .Filter.Eq(info => info.BlockIndex, block.BlockIndex);

            MapTransactionBlock.DeleteMany(transactionFilter);

            // delete the block itself.
            FilterDefinition <MapBlock> blockFilter = Builders <MapBlock> .Filter.Eq(info => info.BlockHash, blockHash);

            MapBlock.DeleteOne(blockFilter);
        }
Exemplo n.º 3
0
        public SyncTransactionInfo BlockTransactionGet(string transactionId)
        {
            FilterDefinition <MapTransactionBlock> filter = Builders <MapTransactionBlock> .Filter.Eq(info => info.TransactionId, transactionId);

            MapTransactionBlock trx = MapTransactionBlock.Find(filter).FirstOrDefault();

            if (trx == null)
            {
                return(null);
            }

            SyncBlockInfo current = BlockGetBlockCount(1).First();

            SyncBlockInfo blk = BlockGetByIndex(trx.BlockIndex);

            return(new SyncTransactionInfo
            {
                BlockIndex = trx.BlockIndex,
                BlockHash = blk.BlockHash,
                Timestamp = blk.BlockTime,
                TransactionHash = trx.TransactionId,
                Confirmations = current.BlockIndex - trx.BlockIndex
            });
        }