コード例 #1
0
 protected AttachmentActionResult(BxDictionary serialized)
 {
     itemUsable = serialized.ContainsKey("itemUsable")
        ? (ItemUsable)ItemFactory.Deserialize((BxDictionary)serialized["itemUsable"])
        : null;
     costume = serialized.ContainsKey("costume")
         ? (Costume)ItemFactory.Deserialize((BxDictionary)serialized["costume"])
         : null;
     tradableFungibleItem = serialized.ContainsKey("tradableFungibleItem")
         ? (ITradableFungibleItem)ItemFactory.Deserialize(
         (BxDictionary)serialized["tradableFungibleItem"])
         : null;
     tradableFungibleItemCount = serialized.ContainsKey("tradableFungibleItemCount")
         ? serialized["tradableFungibleItemCount"].ToInteger()
         : default;
 }
コード例 #2
0
        public RawTransaction(Bencodex.Types.Dictionary dict)
        {
            Nonce       = dict.GetValue <Integer>(NonceKey);
            Signer      = dict.GetValue <Binary>(SignerKey).ToImmutableArray();
            GenesisHash = dict.ContainsKey((IKey)(Binary)GenesisHashKey)
                ? dict.GetValue <Binary>(GenesisHashKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;
            UpdatedAddresses = dict.GetValue <Bencodex.Types.List>(UpdatedAddressesKey)
                               .Select(value => ((Binary)value).ToImmutableArray()).ToImmutableArray();
            PublicKey = dict.GetValue <Binary>(PublicKeyKey).ToImmutableArray();
            Timestamp = dict.GetValue <Text>(TimestampKey);
            Actions   = dict.GetValue <Bencodex.Types.List>(ActionsKey).ToImmutableArray();

            Signature = dict.ContainsKey((IKey)(Binary)SignatureKey)
                ? dict.GetValue <Binary>(SignatureKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;
        }
コード例 #3
0
 /// <summary>
 /// Creates <see cref="BlockDigest"/> instance from
 /// <see cref="Bencodex.Types.Dictionary"/> representation of the <see cref="Block{T}"/>.
 /// </summary>
 /// <param name="dict">
 /// <see cref="Bencodex.Types.Dictionary"/> representation of the <see cref="Block{T}"/>.
 /// </param>
 public BlockDigest(Bencodex.Types.Dictionary dict)
 {
     Header = new BlockHeader(dict.GetValue <Bencodex.Types.Dictionary>(HeaderKey));
     TxIds  = dict.ContainsKey((Binary)TransactionIdsKey)
         ? dict.GetValue <Bencodex.Types.List>(TransactionIdsKey)
              .Select(txId => ((Binary)txId).ToImmutableArray()).ToImmutableArray()
         : ImmutableArray <ImmutableArray <byte> > .Empty;
 }
コード例 #4
0
        public BlockHeader(Bencodex.Types.Dictionary dict)
        {
            ProtocolVersion = dict.ContainsKey(ProtocolVersionKey)
                ? (int)dict.GetValue <Integer>(ProtocolVersionKey)
                : 0;
            Index           = dict.GetValue <Integer>(IndexKey);
            Timestamp       = dict.GetValue <Text>(TimestampKey);
            Difficulty      = dict.GetValue <Integer>(DifficultyKey);
            TotalDifficulty = dict.GetValue <Integer>(TotalDifficultyKey);
            Nonce           = dict.GetValue <Binary>(NonceKey).ToImmutableArray();

            Miner = dict.ContainsKey((IKey)(Binary)MinerKey)
                ? dict.GetValue <Binary>(MinerKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;

            PreviousHash = dict.ContainsKey((IKey)(Binary)PreviousHashKey)
                ? dict.GetValue <Binary>(PreviousHashKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;

            TxHash = dict.ContainsKey((IKey)(Binary)TxHashKey)
                ? dict.GetValue <Binary>(TxHashKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;

            Hash = dict.ContainsKey((IKey)(Binary)HashKey)
                ? dict.GetValue <Binary>(HashKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;

            PreEvaluationHash = dict.ContainsKey((IKey)(Binary)PreEvaluationHashKey)
                ? dict.GetValue <Binary>(PreEvaluationHashKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;

            StateRootHash = dict.ContainsKey((IKey)(Binary)StateRootHashKey)
                ? dict.GetValue <Binary>(StateRootHashKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;
        }
コード例 #5
0
ファイル: Inventory.cs プロジェクト: planetarium/lib9c
 public Item(Bencodex.Types.Dictionary serialized)
 {
     item = ItemFactory.Deserialize(
         (Bencodex.Types.Dictionary)serialized["item"]
         );
     count = (int)((Integer)serialized["count"]).Value;
     if (serialized.ContainsKey("l"))
     {
         Lock = serialized["l"].ToLock();
     }
 }
コード例 #6
0
        public RawBlock(Bencodex.Types.Dictionary dict)
        {
            Index        = dict.GetValue <Integer>(IndexKey);
            Timestamp    = dict.GetValue <Text>(TimestampKey);
            Difficulty   = dict.GetValue <Integer>(DifficultyKey);
            Transactions = dict.GetValue <Bencodex.Types.List>(TransactionsKey)
                           .Select(tx => (byte[])(Binary)tx);
            Nonce = dict.GetValue <Binary>(NonceKey);

            Miner = dict.ContainsKey((Binary)RewardBeneficiaryKey)
                ? dict.GetValue <Binary>(RewardBeneficiaryKey)
                : null;

            PreviousHash = dict.ContainsKey((Binary)PreviousHashKey)
                ? (byte[])dict.GetValue <Binary>(PreviousHashKey)
                : null;

            Hash = dict.ContainsKey((Binary)HashKey)
                ? (byte[])dict.GetValue <Binary>(HashKey)
                : null;
        }
コード例 #7
0
ファイル: BlockHeader.cs プロジェクト: riemannulus/libplanet
        public BlockHeader(Bencodex.Types.Dictionary dict)
        {
            Index      = dict.GetValue <Integer>(IndexKey);
            Timestamp  = dict.GetValue <Text>(TimestampKey);
            Difficulty = dict.GetValue <Integer>(DifficultyKey);
            Nonce      = dict.GetValue <Binary>(NonceKey).ToImmutableArray();

            Miner = dict.ContainsKey((Binary)MinerKey)
                ? dict.GetValue <Binary>(MinerKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;

            PreviousHash = dict.ContainsKey((Binary)PreviousHashKey)
                ? dict.GetValue <Binary>(PreviousHashKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;

            TxHash = dict.ContainsKey((Binary)TxHashKey)
                ? dict.GetValue <Binary>(TxHashKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;

            Hash = dict.ContainsKey((Binary)HashKey)
                ? dict.GetValue <Binary>(HashKey).ToImmutableArray()
                : ImmutableArray <byte> .Empty;
        }
コード例 #8
0
        public RawTransaction(Bencodex.Types.Dictionary dict)
        {
            Nonce            = dict.GetValue <Integer>(NonceKey);
            Signer           = ((byte[])dict.GetValue <Binary>(SignerKey)).ToImmutableArray();
            UpdatedAddresses = To2dArray(
                (byte[])dict.GetValue <Binary>(UpdatedAddressesKey),
                Address.Size);
            PublicKey = ((byte[])dict.GetValue <Binary>(PublicKeyKey)).ToImmutableArray();
            Timestamp = dict.GetValue <Text>(TimestampKey);
            Actions   = dict.GetValue <Bencodex.Types.List>(ActionsKey);

            Signature = dict.ContainsKey((Binary)SignatureKey)
                ? ((byte[])dict.GetValue <Binary>(SignatureKey)).ToImmutableArray()
                : ImmutableArray <byte> .Empty;
        }
コード例 #9
0
ファイル: BlockDigest.cs プロジェクト: longfin/libplanet.net
        public BlockDigest(Bencodex.Types.Dictionary dict)
        {
            var headerDict = dict.GetValue <Bencodex.Types.Dictionary>(HeaderKey);
            var tuple      = BlockMarshaler.UnmarshalPreEvaluationBlockHeader(headerDict);

            _metadata          = tuple.Metadata;
            _nonce             = tuple.Nonce;
            _preEvaluationHash = tuple.PreEvaluationHash;
            StateRootHash      = BlockMarshaler.UnmarshalBlockHeaderStateRootHash(headerDict);
            Signature          = BlockMarshaler.UnmarshalBlockHeaderSignature(headerDict);
            Hash  = BlockMarshaler.UnmarshalBlockHeaderHash(headerDict);
            TxIds = dict.ContainsKey((IKey)(Binary)TransactionIdsKey)
                ? dict.GetValue <Bencodex.Types.List>(TransactionIdsKey)
                    .Select(txId => ((Binary)txId).ToImmutableArray()).ToImmutableArray()
                : ImmutableArray <ImmutableArray <byte> > .Empty;
        }