def insert_transaction(self, pubkey1, pubkey2, assets_traded):
        transaction = {
            "tx": {
                "assets": assets_traded.to_dictionary(),
                "transferred": assets_traded.to_dictionary()
            },
        }
        block = TrustChainBlock.create('tx_done',
                                       transaction,
                                       self.market_db,
                                       pubkey1,
                                       link=None,
                                       link_pk=pubkey2)
        link_block = TrustChainBlock.create('tx_done',
                                            transaction,
                                            self.market_db,
                                            pubkey2,
                                            link=block,
                                            link_pk=pubkey1)

        self.market_db.add_block(block)
        self.market_db.add_block(link_block)
Beispiel #2
0
    def insert_transaction(self, pubkey1, pubkey2, quantity, price):
        transaction = {
            "tx": {
                "quantity_type": quantity.wallet_id,
                "quantity": float(quantity),
                "price_type": price.wallet_id,
                "price": float(price)
            },
        }
        block = TrustChainBlock.create('tx_done',
                                       transaction,
                                       self.market_db,
                                       pubkey1,
                                       link=None,
                                       link_pk=pubkey2)
        link_block = TrustChainBlock.create('tx_done',
                                            transaction,
                                            self.market_db,
                                            pubkey2,
                                            link=block,
                                            link_pk=pubkey1)

        self.market_db.add_block(block)
        self.market_db.add_block(link_block)