model/network.py
def send_transaction(self, transaction: dict, _type: object) -> bool:
        """Stores the transaction sent if it's valid and has valid IDs"""

        if len(self.__info["transactions"]) == MAX_TRANSACTIONS:
            print("Error while adding transaction: Limit of transactions exceeded")
            return False

        if self.is_transaction_valid(transaction, _type) is False:
            print("Error while adding transaction: Invalid transaction")
            return False

        types = {
            Contract: "contract",
            Accusation: "accusation",
            Appeal: "appeal",
            Verdict: "verdict"
        }

        transaction["date"] = str(datetime.datetime.now(datetime.timezone.utc))
        transaction["type"] = types[_type]
        sender = transaction["content"]["sender"]["public_key"]

        if sender in self.__info["transactions"]:
            if len(self.__info["transactions"][sender]) == TRANSACTIONS_LIMIT:
                print("Error while adding transaction: " +
                      "Account exceeded it's transactions limit")
                return False

            self.__info["transactions"][sender].append(transaction)
        else:
            self.__info["transactions"][sender] = [transaction]

        self.save()

        return True
Stores the transaction sent if it's valid and has valid IDs
Stores the transaction sent if it's valid and has valid IDs
Stores the transaction sent if it ' s valid and has valid IDs
def send_transaction(self, transaction: dict, _type: object) -> bool:
        if len(self.__info["transactions"]) == MAX_TRANSACTIONS:
            print("Error while adding transaction: Limit of transactions exceeded")
            return False
        if self.is_transaction_valid(transaction, _type) is False:
            print("Error while adding transaction: Invalid transaction")
            return False
        types = {
            Contract: "contract",
            Accusation: "accusation",
            Appeal: "appeal",
            Verdict: "verdict"
        }
        transaction["date"] = str(datetime.datetime.now(datetime.timezone.utc))
        transaction["type"] = types[_type]
        sender = transaction["content"]["sender"]["public_key"]
        if sender in self.__info["transactions"]:
            if len(self.__info["transactions"][sender]) == TRANSACTIONS_LIMIT:
                print("Error while adding transaction: " +
                      "Account exceeded it's transactions limit")
                return False
            self.__info["transactions"][sender].append(transaction)
        else:
            self.__info["transactions"][sender] = [transaction]
        self.save()
        return True
def send_transaction ( self , transaction : dict , _type : object ) -> bool : if len ( self . __info [ "transactions" ] ) == MAX_TRANSACTIONS : print ( "Error while adding transaction: Limit of transactions exceeded" ) return False if self . is_transaction_valid ( transaction , _type ) is False : print ( "Error while adding transaction: Invalid transaction" ) return False types = { Contract : "contract" , Accusation : "accusation" , Appeal : "appeal" , Verdict : "verdict" } transaction [ "date" ] = str ( datetime . datetime . now ( datetime . timezone . utc ) ) transaction [ "type" ] = types [ _type ] sender = transaction [ "content" ] [ "sender" ] [ "public_key" ] if sender in self . __info [ "transactions" ] : if len ( self . __info [ "transactions" ] [ sender ] ) == TRANSACTIONS_LIMIT : print ( "Error while adding transaction: " + "Account exceeded it's transactions limit" ) return False self . __info [ "transactions" ] [ sender ] . append ( transaction ) else : self . __info [ "transactions" ] [ sender ] = [ transaction ] self . save ( ) return True
Stores the transaction sent if it's valid and has valid IDs
Stores the transaction sent if it ' s valid and has valid IDs
"""Stores the transaction sent if it's valid and has valid IDs"""
self
transaction
dict
_type
object