Пример #1
0
        public static Transaction <T> CreateUnsigned(
            long nonce,
            PublicKey publicKey,
            BlockHash?genesisHash,
            IEnumerable <T> actions,
            IImmutableSet <Address> updatedAddresses = null,
            DateTimeOffset?timestamp = null
            )
        {
            var signer = new Address(publicKey);

            if (ReferenceEquals(updatedAddresses, null))
            {
                updatedAddresses = ImmutableHashSet <Address> .Empty;
            }

            DateTimeOffset ts = timestamp ?? DateTimeOffset.UtcNow;

            ImmutableArray <T> actionsArray = actions.ToImmutableArray();

            if (!actionsArray.IsEmpty)
            {
                // FIXME: Although we are assuming all block hashes are SHA256 digest, we should
                // parametrize this in the future.
                BlockHash emptyBlockHash = BlockHash.FromHashDigest(default(HashDigest <SHA256>));

                var evalUpdatedAddresses = ActionEvaluator <T> .GetUpdatedAddresses(
                    new Transaction <T>(
                        nonce,
                        signer,
                        publicKey,
                        genesisHash,
                        updatedAddresses,
                        ts,
                        actionsArray));

                if (!updatedAddresses.IsSupersetOf(evalUpdatedAddresses))
                {
                    updatedAddresses = updatedAddresses.Union(evalUpdatedAddresses);
                }
            }

            return(new Transaction <T>(
                       nonce,
                       signer,
                       publicKey,
                       genesisHash,
                       updatedAddresses,
                       ts,
                       actionsArray));
        }