Пример #1
0
        public override string ToString()
        {
            StringBuilder retVal = new StringBuilder();

            retVal.Append(BlockType.ToString());
            retVal.Append(BlockNumber.ToString());
            retVal.Append(" : ");
            if (Name != null)
            {
                retVal.Append(Name);
            }
            retVal.Append("\r\n\r\n");

            if (Description != null)
            {
                retVal.Append("Description\r\n\t");
                retVal.Append(Description.Replace("\n", "\r\n\t"));
                retVal.Append("\r\n\r\n");
            }

            retVal.Append("SRC-Code\r\n");

            retVal.Append(Text);
            retVal.Append("\r\n");

            return(retVal.ToString());
        }
 /// <summary>
 ///     Constructor.
 /// </summary>
 /// <param name="gameRoundId">The game round id</param>
 /// <param name="createdByAccount">The account that created the game.</param>
 /// <param name="network">The network.</param>
 /// <param name="gameManagerContract">The game manager contract.</param>
 /// <param name="gameContract">The game network contract</param>
 /// <param name="seedCommit">The commit seed</param>
 /// <param name="seedReveal">The reveal seed</param>
 /// <param name="status">Status of game round</param>
 /// <param name="roundDuration">Round duration in seconds.</param>
 /// <param name="bettingCloseDuration">Duration of how long the betting close period is in seconds.</param>
 /// <param name="roundTimeoutDuration">Round timeout duration in seconds.</param>
 /// <param name="dateCreated">The date/time the round was created (transaction submitted)</param>
 /// <param name="dateUpdated">The date/time the round last updated</param>
 /// <param name="dateStarted">The date/time the round was activated (mined)</param>
 /// <param name="dateClosed">The date/time the round was closed.</param>
 /// <param name="blockNumberCreated">The block number the round was activated.</param>
 public GameRound(GameRoundId gameRoundId,
                  AccountAddress createdByAccount,
                  EthereumNetwork network,
                  ContractAddress gameManagerContract,
                  ContractAddress gameContract,
                  Seed seedCommit,
                  Seed seedReveal,
                  GameRoundStatus status,
                  TimeSpan roundDuration,
                  TimeSpan bettingCloseDuration,
                  TimeSpan roundTimeoutDuration,
                  DateTime dateCreated,
                  DateTime dateUpdated,
                  DateTime?dateStarted,
                  DateTime?dateClosed,
                  BlockNumber blockNumberCreated)
 {
     this.GameRoundId         = gameRoundId ?? throw new ArgumentNullException(nameof(gameRoundId));
     this.CreatedByAccount    = createdByAccount ?? throw new ArgumentNullException(nameof(createdByAccount));
     this.Network             = network ?? throw new ArgumentNullException(nameof(network));
     this.GameManagerContract = gameManagerContract ?? throw new ArgumentNullException(nameof(gameManagerContract));
     this.GameContract        = gameContract ?? throw new ArgumentNullException(nameof(gameContract));
     this.SeedCommit          = seedCommit ?? throw new ArgumentNullException(nameof(seedCommit));
     this.SeedReveal          = seedReveal ?? throw new ArgumentNullException(nameof(seedReveal));
     this.Status               = status;
     this.RoundDuration        = roundDuration;
     this.BettingCloseDuration = bettingCloseDuration;
     this.RoundTimeoutDuration = roundTimeoutDuration;
     this.DateCreated          = dateCreated;
     this.DateUpdated          = dateUpdated;
     this.DateStarted          = dateStarted;
     this.DateClosed           = dateClosed;
     this.BlockNumberCreated   = blockNumberCreated;
 }
Пример #3
0
        public async Task <HttpResponseMessage> UpdateGameStatus(int tournamentId, string tennisEventId, [FromBody] JsonElement json)
        {
            var gameResult           = new GameResult();
            var gameStatus           = JsonConverter.ToEnumeration <GameStatus>(json.GetProperty("gameStatus"));
            var playerClassification = JsonConverter.ToEnumeration <PlayerClassification>(json.GetProperty("playerClassification"));
            var entryNumber          = EntryNumber.FromValue(JsonConverter.ToNullableInt32(json.GetProperty("entryNumber")));
            var gameScore            = new GameScore(JsonConverter.ToString(json.GetProperty("gameScore")));

            gameResult.UpdateGameResult(
                gameStatus,
                playerClassification,
                entryNumber,
                gameScore
                );

            var blockNumber = new BlockNumber(JsonConverter.ToInt32(json.GetProperty("blockNumber")));
            var gameNumber  = new GameNumber(JsonConverter.ToInt32(json.GetProperty("gameNumber")));

            await this.drawTableUseCase.UpdateGameStatus(
                tournamentId,
                tennisEventId,
                blockNumber,
                gameNumber,
                gameResult
                );

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Пример #4
0
        /// <inheritdoc />
        public async Task <IEventLock?> LockEventForProcessingAsync(EthereumNetwork network,
                                                                    ContractAddress contractAddresses,
                                                                    EventSignature eventSignature,
                                                                    TransactionHash transactionHash,
                                                                    int eventIndex,
                                                                    BlockNumber blockNumber,
                                                                    GasLimit gasUsed,
                                                                    GasPrice gasPrice,
                                                                    EventRetrievalStrategy retrievalStrategy)
        {
            var param = new
            {
                Network         = network.Name,
                ContractAddress = contractAddresses,
                EventSignature  = eventSignature,
                TransactionHash = transactionHash,
                EventIndex      = eventIndex,
                MachineName     = this._machineName,
                BlockNumber     = (int)blockNumber.Value,
                GasUsed         = gasUsed,
                GasPrice        = gasPrice,
                Strategy        = retrievalStrategy.GetName()
            };

            return(await this._database.QuerySingleOrDefaultAsync <object, EventLockEntity>(storedProcedure : @"Ethereum.Event_Lock", param : param));
        }
Пример #5
0
        public void Create(Hash id, Hash dna, BlockNumber genesis, Balance price, U32 gen, EnumType <RarityType> rarity)
        {
            var start = 0;

            Id     = id;
            start += id.Bytes.Length;

            Dna    = dna;
            start += dna.Bytes.Length;

            Genesis = genesis;
            start  += genesis.Bytes.Length;

            Price  = price;
            start += price.Bytes.Length;

            Gen    = gen;
            start += gen.Bytes.Length;

            Gen    = gen;
            start += gen.Bytes.Length;

            Rarity = rarity;
            start += rarity.Bytes.Length;

            _size = start;
        }
 /// <inheritdoc />
 public Task SaveStartRoundAsync(GameRoundId gameRoundId,
                                 EthereumNetwork network,
                                 AccountAddress createdByAccount,
                                 ContractAddress gameManagerContract,
                                 ContractAddress gameContract,
                                 Seed seedCommit,
                                 Seed seedReveal,
                                 TimeSpan roundDuration,
                                 TimeSpan bettingCloseDuration,
                                 TimeSpan roundTimeoutDuration,
                                 BlockNumber blockNumberCreated,
                                 TransactionHash transactionHash)
 {
     return(this._database.ExecuteAsync(storedProcedure: @"Games.GameRound_Insert",
                                        new
     {
         GameRoundId = gameRoundId,
         GameManagerContract = gameManagerContract,
         GameContract = gameContract,
         CreatedByAccount = createdByAccount,
         Network = network.Name,
         BlockNumberCreated = blockNumberCreated,
         SeedCommit = seedCommit,
         SeedReveal = seedReveal,
         BettingCloseDuration = bettingCloseDuration.TotalSeconds,
         RoundDuration = roundDuration.TotalSeconds,
         RoundTimeoutDuration = roundTimeoutDuration.TotalSeconds,
         TransactionHash = transactionHash
     }));
 }
Пример #7
0
        /// <summary>
        /// エントリー詳細の新しいインスタンスを生成します。
        /// </summary>
        /// <param name="entryNumber">エントリー番号。</param>
        /// <param name="participationClassification">出場区分。</param>
        /// <param name="seedNumber">シード番号。</param>
        /// <param name="entryPlayers">選手情報一覧。</param>
        /// <param name="canParticipationDates">出場可能日一覧。</param>
        /// <param name="receiptStatus">受領状況。</param>
        /// <param name="usageFeatures">利用機能。</param>
        /// <param name="fromQualifying">予選からの進出者かどうか示す値。</param>
        /// <param name="blockNumber">ブロック番号。</param>
        public EntryDetail(
            EntryNumber entryNumber,
            ParticipationClassification participationClassification,
            SeedNumber seedNumber,
            IEnumerable <EntryPlayer> entryPlayers,
            IEnumerable <CanParticipationDate> canParticipationDates,
            ReceiptStatus receiptStatus,
            UsageFeatures usageFeatures,
            bool fromQualifying     = false,
            BlockNumber blockNumber = null)
        {
            this.EntryNumber = entryNumber;
            this.ParticipationClassification = participationClassification;
            this.SeedNumber            = seedNumber;
            this.EntryPlayers          = new EntryPlayers(entryPlayers);
            this.CanParticipationDates = new CanParticipationDates(canParticipationDates);
            this.ReceiptStatus         = receiptStatus;
            this.UsageFeatures         = usageFeatures;
            this.FromQualifying        = fromQualifying;

            if (!this.FromQualifying)
            {
                return;
            }

            this.BlockNumber = blockNumber ?? throw new ArgumentNullException("ブロック番号");
        }
Пример #8
0
        public string createINodeString()
        {
            string inodeAttributes =
                INodeNumber.ToString().Trim() + Command.INODE_ATTRIBUTE_SEPARATOR_CHR
                + Filename + Command.INODE_ATTRIBUTE_SEPARATOR_CHR
                + Directory + Command.INODE_ATTRIBUTE_SEPARATOR_CHR
                + FileSize.ToString() + Command.INODE_ATTRIBUTE_SEPARATOR_CHR
                + BlockNumber.ToString() + Command.INODE_ATTRIBUTE_SEPARATOR_CHR;

            return(inodeAttributes);
        }
Пример #9
0
            public async Task ThrowsBlockNotFoundException()
            {
                //setup
                Web3Mock.GetBlockWithTransactionsByNumberMock
                .Setup(p => p.SendRequestAsync(BlockNumber.ToHexBigInteger(), null))
                .ReturnsAsync((BlockWithTransactions)null);

                //execute
                await Assert.ThrowsAsync <BlockNotFoundException>(
                    async() => await BlockProcessor.ProcessBlockAsync(BlockNumber));
            }
Пример #10
0
        public override void Decode(byte[] byteArray, ref int p)
        {
            var start = p;

            Height = new BlockNumber();
            Height.Decode(byteArray, ref p);

            Index = new U32();
            Index.Decode(byteArray, ref p);

            _size = p - start;
        }
Пример #11
0
        public async Task GetChainAsync()
        {
            var cts = new CancellationTokenSource();
            await _substrateClient.ConnectAsync(cts.Token);

            var blockNumber = new BlockNumber();

            blockNumber.Create(0);

            var blockHash = await _substrateClient.Chain.GetBlockHashAsync(blockNumber);

            var blockHash1 = await _substrateClient.Chain.GetBlockHashAsync(blockNumber, cts.Token);

            Assert.AreEqual("Hash", blockHash.GetType().Name);
            Assert.AreEqual("Hash", blockHash1.GetType().Name);


            var block0 = await _substrateClient.Chain.GetBlockAsync();

            var block1 = await _substrateClient.Chain.GetBlockAsync(cts.Token);

            var block2 = await _substrateClient.Chain.GetBlockAsync(blockHash as Hash);

            var block3 = await _substrateClient.Chain.GetBlockAsync(blockHash as Hash, cts.Token);

            Assert.AreEqual("BlockData", block0.GetType().Name);
            Assert.AreEqual("BlockData", block1.GetType().Name);
            Assert.AreEqual("BlockData", block2.GetType().Name);
            Assert.AreEqual("BlockData", block3.GetType().Name);

            var header0 = await _substrateClient.Chain.GetHeaderAsync();

            var header1 = await _substrateClient.Chain.GetHeaderAsync(cts.Token);

            var header2 = await _substrateClient.Chain.GetHeaderAsync(blockHash as Hash);

            var header3 = await _substrateClient.Chain.GetHeaderAsync(blockHash as Hash, cts.Token);

            Assert.AreEqual("Header", header0.GetType().Name);
            Assert.AreEqual("Header", header1.GetType().Name);
            Assert.AreEqual("Header", header2.GetType().Name);
            Assert.AreEqual("Header", header3.GetType().Name);

            var finalizedHeader = await _substrateClient.Chain.GetFinalizedHeadAsync();

            var finalizedHeader1 = await _substrateClient.Chain.GetFinalizedHeadAsync(cts.Token);

            Assert.AreEqual("Hash", finalizedHeader.GetType().Name);
            Assert.AreEqual("Hash", finalizedHeader1.GetType().Name);

            await _substrateClient.CloseAsync();
        }
Пример #12
0
 public object ToJson()
 => new
 {
     removed          = Removed,
     logIndex         = LogIndex?.ToJson(),
     transactionIndex = TransactionIndex?.ToJson(),
     transactionHash  = TransactionHash?.ToJson(),
     blockHash        = BlockHash?.ToJson(),
     blockNumber      = BlockNumber?.ToJson(),
     address          = Address?.ToJson(),
     data             = Data?.ToJson(),
     topics           = Topics?.Select(t => t.ToJson()).ToArray()
 };
Пример #13
0
        private Response GetEthereumTransactions(string hashBlockNumber)
        {
            using (var client = new HttpClient())
            {
                AddMapHeader(client);

                var body = new BlockNumber()
                {
                    Method = _configuration["Api:Method"],
                    Params = new ArrayList()
                    {
                        hashBlockNumber, true
                    }
                };

                string defaultErrorCode = string.Empty;
                string defaultErrorMessage;
                try
                {
                    var response = client.PostAsync(_configuration["Api:Url"],
                                                    new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json")).Result;
                    if (response != null && response.IsSuccessStatusCode)
                    {
                        var      Content     = response.Content.ReadAsStringAsync().Result;
                        Response orderResult = JsonConvert.DeserializeObject <Response>(Content);

                        return(orderResult);
                    }
                    else
                    {
                        defaultErrorCode    = response?.StatusCode.ToString();
                        defaultErrorMessage = response?.Content?.ToString();
                        _logger.LogError($"Failed Response Status, {response.StatusCode} from Web Api. Message : {response.Content}", this);
                    }
                }
                catch (Exception ex)
                {
                    defaultErrorMessage = ex.Message;
                    _logger.LogError($"Failed to get transactions {ex.Message} from Web Api.", ex, this);
                }

                return(new Response()
                {
                    Error = new Error()
                    {
                        Code = defaultErrorCode, Message = defaultErrorMessage
                    }
                });
            }
        }
Пример #14
0
    List <int> GetThroughBlockList(int floor, int getDirection, bool onCloud)
    {
        switch (floor)
        {
        case 1:
            return(BlockNumber.GetDownstairThroughBlock(getDirection, onCloud));

        case 2:
            return(BlockNumber.GetUpstairThroughBlock(getDirection, onCloud));

        case 3:
            return(BlockNumber.GetThirdFloorThroughBlock(getDirection, onCloud));
        }

        return(new List <int>());
    }
Пример #15
0
 public object ToJson()
 {
     return(new
     {
         transactionHash = TransactionHash?.ToJson(),
         transactionIndex = TransactionIndex?.ToJson(),
         blockHash = BlockHash?.ToJson(),
         blockNumber = BlockNumber?.ToJson(),
         cumulativeGasUsed = CumulativeGasUsed?.ToJson(),
         gasUsed = GasUsed?.ToJson(),
         contractAddress = ContractAddress?.ToJson(),
         logs = Logs?.Select(x => x.ToJson()).ToArray(),
         logsBloom = LogsBloom?.ToJson(),
         root = Root?.ToJson(),
         status = Status?.ToJson()
     });
 }
Пример #16
0
 public object ToJson()
 {
     return(new
     {
         hash = Hash.ToJson(),
         nonce = Nonce.ToJson(),
         blockHash = BlockHash.ToJson(),
         blockNumber = BlockNumber.ToJson(),
         transactionIndex = TransactionIndex.ToJson(),
         from = From.ToJson(),
         to = To.ToJson(),
         value = Value.ToJson(),
         gasPrice = GasPrice.ToJson(),
         gas = Gas.ToJson(),
         input = Data.ToJson(),
     });
 }
        public override string ToString()
        {
            int           bytecnt = 0;
            StringBuilder retVal  = new StringBuilder();

            retVal.Append(BlockType.ToString());
            retVal.Append(BlockNumber.ToString());
            retVal.Append(" : ");
            if (Name != null)
            {
                retVal.Append(Name);
            }
            retVal.Append("\r\n\r\n");

            if (Description != null)
            {
                retVal.Append("Description\r\n\t");
                retVal.Append(Description.Replace("\n", "\r\n\t"));
                retVal.Append("\r\n\r\n");
            }

            if (Parameter != null)
            {
                retVal.Append("Parameter\r\n");
                foreach (S5Parameter par in Parameter)
                {
                    retVal.Append("\t" + par.ToString() + "\r\n");
                }
                retVal.Append("\r\n");
            }

            retVal.Append("AWL-Code\r\n");

            if (AWLCode != null)
            {
                foreach (var plcFunctionBlockRow in AWLCode)
                {
                    //retVal.Append(/* "0x" + */ bytecnt.ToString(/* "X" */).PadLeft(4, '0') + "  :");
                    retVal.Append(plcFunctionBlockRow.ToString());
                    retVal.Append("\r\n");
                    //bytecnt += plcFunctionBlockRow.ByteSize;
                }
            }
            return(retVal.ToString());
        }
Пример #18
0
        public void MogwaiStructTest()
        {
            var mogwaiStructStr = "0x89ab510f57802886c16922685a376edb536f762584dda569cda67381c4e4dec889ab510f57802886c16922685a376edb536f762584dda569cda67381c4e4dec871000000000000000000000000000000000000000000000000";
            var mogwaiStructA   = new MogwaiStruct();

            mogwaiStructA.Create(mogwaiStructStr);


            var mogwaiStructB = new MogwaiStruct();

            var id = new Hash();

            id.Create(mogwaiStructA.Id.Value);

            var dna = new Hash();

            dna.Create(mogwaiStructA.Dna.Value);

            var genesis = new BlockNumber();

            genesis.Create(mogwaiStructA.Genesis.Value);

            var price = new Balance();

            price.Create(mogwaiStructA.Price.Value);

            var gen = new U32();

            gen.Create(mogwaiStructA.Gen.Value);

            var rarity = new EnumType <RarityType>();

            rarity.Create(mogwaiStructA.Rarity.Bytes);

            mogwaiStructB.Create(id, dna, genesis, price, gen, rarity);

            Assert.AreEqual(mogwaiStructB.Id.Value, mogwaiStructA.Id.Value);
            Assert.AreEqual(mogwaiStructB.Dna.Value, mogwaiStructA.Dna.Value);
            Assert.AreEqual(mogwaiStructB.Genesis.Value, mogwaiStructA.Genesis.Value);
            Assert.AreEqual(mogwaiStructB.Price.Value, mogwaiStructA.Price.Value);
            Assert.AreEqual(mogwaiStructB.Gen.Value, mogwaiStructA.Gen.Value);
            Assert.AreEqual(mogwaiStructB.Rarity.Value, mogwaiStructA.Rarity.Value);
        }
Пример #19
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (TransactionId != null ? TransactionId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Hash != null ? Hash.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Size.GetHashCode();
         hashCode = (hashCode * 397) ^ Vsize.GetHashCode();
         hashCode = (hashCode * 397) ^ Version.GetHashCode();
         hashCode = (hashCode * 397) ^ LockTime.GetHashCode();
         hashCode = (hashCode * 397) ^ (Blockhash != null ? Blockhash.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ BlockNumber.GetHashCode();
         hashCode = (hashCode * 397) ^ Confirmations.GetHashCode();
         hashCode = (hashCode * 397) ^ (Time != null ? Time.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (VIn != null ? VIn.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (VOut != null ? VOut.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #20
0
        public override string ToString()
        {
            string retVal = "";

            if (this.BlockType == PLCBlockType.UDT)
            {
                retVal += "UDT";
            }
            else
            {
                retVal += "DB";
            }
            retVal += BlockNumber.ToString() + Environment.NewLine;
            if (Structure != null)
            {
                retVal += Structure.ToString();
            }
            return(retVal);
        }
 /// <inheritdoc />
 public Task SaveEndRoundAsync(GameRoundId gameRoundId,
                               BlockNumber blockNumberCreated,
                               TransactionHash transactionHash,
                               WinAmount[] winAmounts,
                               WinLoss progressivePotWinLoss,
                               byte[] gameResult,
                               byte[] history)
 {
     return(this._database.ExecuteAsync(storedProcedure: @"Games.GameRound_Complete",
                                        new
     {
         GameRoundId = gameRoundId,
         BlockNumber = blockNumberCreated,
         TransactionHash = transactionHash,
         WinAmounts = this._winAmountTableBuilder.Build(winAmounts.Select(Convert)),
         ProgressiveWinLoss = progressivePotWinLoss,
         GameResult = gameResult,
         History = history
     }));
 }
Пример #22
0
            public WhenBlockIsNotNull()
            {
                _stubBlock = new BlockWithTransactions
                {
                    Number       = new HexBigInteger(BlockNumber),
                    Transactions = new[]
                    {
                        new Transaction {
                            TransactionHash = TxHash1
                        },
                        new Transaction {
                            TransactionHash = TxHash2
                        }
                    }
                };

                Web3Mock.GetBlockWithTransactionsByNumberMock
                .Setup(p => p.SendRequestAsync(BlockNumber.ToHexBigInteger(), null))
                .ReturnsAsync(_stubBlock);
            }
Пример #23
0
        public async Task CheckStorageCallsAsync()
        {
            // create new wallet with password and persist
            var wallet = new Wallet();

            await wallet.StartAsync();

            Assert.True(wallet.IsConnected);

            wallet.Load("dev_wallet");

            await wallet.UnlockAsync("aA1234dd");

            Assert.True(wallet.IsUnlocked);

            Assert.AreEqual("5FfzQe73TTQhmSQCgvYocrr6vh1jJXEKB8xUB6tExfpKVCEZ", wallet.Account.Value);

            Thread.Sleep(1000);

            Assert.True(BigInteger.Parse("400000000000000") < wallet.AccountInfo.AccountData.Free.Value);
            Assert.True(BigInteger.Parse("600000000000000") > wallet.AccountInfo.AccountData.Free.Value);

            var blockNumber = new BlockNumber();

            blockNumber.Create(10);
            var blockHash = await wallet.Client.Chain.GetBlockHashAsync(blockNumber);

            var header = await wallet.Client.Chain.GetHeaderAsync(blockHash);

            Assert.AreEqual(10, header.Number.Value);

            var countMogwais = (U64)await wallet.Client.GetStorageAsync("DotMogModule", "OwnedMogwaisCount",
                                                                        new[] { Utils.Bytes2HexString(wallet.Account.Bytes) });

            Assert.AreEqual(1, countMogwais.Value);


            await wallet.StopAsync();

            Assert.False(wallet.IsConnected);
        }
Пример #24
0
        private static async Task RunBlockCallsAsync(CancellationToken cancellationToken)
        {
            using var client = new SubstrateClient(new Uri(Websocketurl));

            client.RegisterTypeConverter(new GenericTypeConverter <MogwaiStruct>());

            await client.ConnectAsync(cancellationToken);

            var systemName = await client.System.NameAsync(cancellationToken);

            var systemVersion = await client.System.VersionAsync(cancellationToken);

            var systemChain = await client.System.ChainAsync(cancellationToken);

            Console.WriteLine($"Connected to System: {systemName} Chain: {systemChain} Version: {systemVersion}.");
            // 544133 CreateMogwai();
            for (uint i = 0; i < 10; i++)
            {
                var blockNumber = new BlockNumber();
                blockNumber.Create(i);
                Console.WriteLine(blockNumber.Encode());

                Console.WriteLine(Utils.Bytes2HexString(blockNumber.Encode()));

                var blockHash = await client.Chain.GetBlockHashAsync(blockNumber, cancellationToken);

                //var block = await client.Chain.GetBlockAsync(blockHash, cancellationToken);

                // Print result
                //Console.WriteLine($"{i} --> {block.Block.Extrinsics.Length}");
                Console.WriteLine($"{i} --> {blockHash.Value}");
            }
            //Console.WriteLine(client.MetaData.Serialize());

            Console.ReadKey();

            // Close connection
            await client.CloseAsync(cancellationToken);
        }
Пример #25
0
    //ブロックが壊れたときに実行する
    public void BreakBlock(BlockNumber block_num)
    {
        if (block_num.line < BlockArray.GetLength(0) - 1 &&
            BlockArray[block_num.line + 1, block_num.row, block_num.height].renderer)
        {
            BlockArray[block_num.line + 1, block_num.row, block_num.height].renderer.enabled = true;
        }

        if (block_num.line > 0 &&
            BlockArray[block_num.line - 1, block_num.row, block_num.height].renderer)
        {
            BlockArray[block_num.line - 1, block_num.row, block_num.height].renderer.enabled = true;
        }

        if (block_num.row < BlockArray.GetLength(1) - 1 &&
            BlockArray[block_num.line, block_num.row + 1, block_num.height].renderer)
        {
            BlockArray[block_num.line, block_num.row + 1, block_num.height].renderer.enabled = true;
        }

        if (block_num.row > 0 &&
            BlockArray[block_num.line, block_num.row - 1, block_num.height].renderer)
        {
            BlockArray[block_num.line, block_num.row - 1, block_num.height].renderer.enabled = true;
        }

        if (block_num.height < BlockArray.GetLength(2) - 1 &&
            BlockArray[block_num.line, block_num.row, block_num.height + 1].renderer)
        {
            BlockArray[block_num.line, block_num.row, block_num.height + 1].renderer.enabled = true;
        }

        if (block_num.height > 0 &&
            BlockArray[block_num.line, block_num.row, block_num.height - 1].renderer)
        {
            BlockArray[block_num.line, block_num.row, block_num.height - 1].renderer.enabled = true;
        }
    }
Пример #26
0
        public override void Decode(byte[] byteArray, ref int p)
        {
            var start = p;

            Id = new Hash();
            Id.Decode(byteArray, ref p);

            Dna = new Hash();
            Dna.Decode(byteArray, ref p);

            Genesis = new BlockNumber();
            Genesis.Decode(byteArray, ref p);

            Price = new Balance();
            Price.Decode(byteArray, ref p);

            Gen = new U32();
            Gen.Decode(byteArray, ref p);

            Rarity = new EnumType <RarityType>();
            Rarity.Decode(byteArray, ref p);

            _size = p - start;
        }
Пример #27
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Chain != null ? Chain.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TokenTransfers != null ? TokenTransfers.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Index;
         hashCode = (hashCode * 397) ^ (TransactionHash != null ? TransactionHash.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Value.GetHashCode();
         hashCode = (hashCode * 397) ^ (FromAddress != null ? FromAddress.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ToAddress != null ? ToAddress.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Date != null ? Date.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (BlockHash != null ? BlockHash.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ BlockNumber.GetHashCode();
         hashCode = (hashCode * 397) ^ Gas.GetHashCode();
         hashCode = (hashCode * 397) ^ GasPrice.GetHashCode();
         hashCode = (hashCode * 397) ^ GasUsed.GetHashCode();
         hashCode = (hashCode * 397) ^ Nonce.GetHashCode();
         hashCode = (hashCode * 397) ^ Confirmations.GetHashCode();
         hashCode = (hashCode * 397) ^ (Input != null ? Input.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #28
0
        public override void Decode(byte[] byteArray, ref int p)
        {
            var start = p;

            Id = new Hash();
            Id.Decode(byteArray, ref p);

            Begin = new BlockNumber();
            Begin.Decode(byteArray, ref p);

            Duration = new U16();
            Duration.Decode(byteArray, ref p);

            EventType = new EnumType <GameEventType>();
            EventType.Decode(byteArray, ref p);

            Hashes = new Vec <Hash>();
            Hashes.Decode(byteArray, ref p);

            Value = new U64();
            Value.Decode(byteArray, ref p);

            _size = p - start;
        }
Пример #29
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                int hash = 41;

                // Suitable nullity checks
                hash = hash * 59 + Id.GetHashCode();
                hash = hash * 59 + StartDate.GetHashCode();
                hash = hash * 59 + EndDate.GetHashCode();

                if (LocalArea != null)
                {
                    hash = hash * 59 + LocalArea.GetHashCode();
                }

                if (Equipment != null)
                {
                    hash = hash * 59 + Equipment.GetHashCode();
                }

                if (BlockNumber != null)
                {
                    hash = hash * 59 + BlockNumber.GetHashCode();
                }

                if (Owner != null)
                {
                    hash = hash * 59 + Owner.GetHashCode();
                }

                if (OwnerOrganizationName != null)
                {
                    hash = hash * 59 + OwnerOrganizationName.GetHashCode();
                }

                if (Seniority != null)
                {
                    hash = hash * 59 + Seniority.GetHashCode();
                }

                if (ServiceHoursLastYear != null)
                {
                    hash = hash * 59 + ServiceHoursLastYear.GetHashCode();
                }

                if (ServiceHoursTwoYearsAgo != null)
                {
                    hash = hash * 59 + ServiceHoursTwoYearsAgo.GetHashCode();
                }

                if (ServiceHoursThreeYearsAgo != null)
                {
                    hash = hash * 59 + ServiceHoursThreeYearsAgo.GetHashCode();
                }

                if (IsSeniorityOverridden != null)
                {
                    hash = hash * 59 + IsSeniorityOverridden.GetHashCode();
                }

                if (SeniorityOverrideReason != null)
                {
                    hash = hash * 59 + SeniorityOverrideReason.GetHashCode();
                }

                return(hash);
            }
        }
Пример #30
0
        /// <summary>
        /// Returns true if SeniorityAudit instances are equal
        /// </summary>
        /// <param name="other">Instance of SeniorityAudit to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SeniorityAudit other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     StartDate == other.StartDate ||
                     StartDate.Equals(other.StartDate)
                 ) &&
                 (
                     EndDate == other.EndDate ||
                     EndDate.Equals(other.EndDate)
                 ) &&
                 (
                     LocalArea == other.LocalArea ||
                     LocalArea != null &&
                     LocalArea.Equals(other.LocalArea)
                 ) &&
                 (
                     Equipment == other.Equipment ||
                     Equipment != null &&
                     Equipment.Equals(other.Equipment)
                 ) &&
                 (
                     BlockNumber == other.BlockNumber ||
                     BlockNumber != null &&
                     BlockNumber.Equals(other.BlockNumber)
                 ) &&
                 (
                     Owner == other.Owner ||
                     Owner != null &&
                     Owner.Equals(other.Owner)
                 ) &&
                 (
                     OwnerOrganizationName == other.OwnerOrganizationName ||
                     OwnerOrganizationName != null &&
                     OwnerOrganizationName.Equals(other.OwnerOrganizationName)
                 ) &&
                 (
                     Seniority == other.Seniority ||
                     Seniority != null &&
                     Seniority.Equals(other.Seniority)
                 ) &&
                 (
                     ServiceHoursLastYear == other.ServiceHoursLastYear ||
                     ServiceHoursLastYear != null &&
                     ServiceHoursLastYear.Equals(other.ServiceHoursLastYear)
                 ) &&
                 (
                     ServiceHoursTwoYearsAgo == other.ServiceHoursTwoYearsAgo ||
                     ServiceHoursTwoYearsAgo != null &&
                     ServiceHoursTwoYearsAgo.Equals(other.ServiceHoursTwoYearsAgo)
                 ) &&
                 (
                     ServiceHoursThreeYearsAgo == other.ServiceHoursThreeYearsAgo ||
                     ServiceHoursThreeYearsAgo != null &&
                     ServiceHoursThreeYearsAgo.Equals(other.ServiceHoursThreeYearsAgo)
                 ) &&
                 (
                     IsSeniorityOverridden == other.IsSeniorityOverridden ||
                     IsSeniorityOverridden != null &&
                     IsSeniorityOverridden.Equals(other.IsSeniorityOverridden)
                 ) &&
                 (
                     SeniorityOverrideReason == other.SeniorityOverrideReason ||
                     SeniorityOverrideReason != null &&
                     SeniorityOverrideReason.Equals(other.SeniorityOverrideReason)
                 ));
        }