コード例 #1
0
        def created_nonced_transaction():
            t = BlockchainTransaction(
                first_block_hash=persistence_module.first_block_hash)
            t.signing_wallet = wallet
            db_session.add(t)
            db_session.commit()

            nonce = persistence_module.locked_claim_transaction_nonce(
                network_nonce=starting_nonce,
                signing_wallet_id=wallet.id,
                transaction_id=t.id)

            t.nonce_consumed = True

            return t, nonce
コード例 #2
0
    def _claim_transaction_nonce(
        self,
        network_nonce: int,
        signing_wallet: BlockchainWallet,
        transaction: BlockchainTransaction,
    ) -> int:

        if transaction.nonce is not None:
            return transaction.nonce
        calculated_nonce = self._calculate_nonce(signing_wallet, network_nonce)
        transaction.signing_wallet = signing_wallet
        transaction.nonce = calculated_nonce
        transaction.status = 'PENDING'

        # TODO: can we shift this commit out?
        self.session.commit()

        return calculated_nonce