def add_messsaction(self, sender, follower, message, signature, is_receiving=False): """ Arguments: :sender: The sender of the coins. :follower: The follower :message: The message from the supporter. """ messsaction = Messsaction(sender, follower, message, signature) if Verification.verify_messsaction(messsaction, sender, follower): self.__open_messsactions.append(messsaction) self.save_data() if not is_receiving: for node in self.__peer_nodes: url = 'http://{}/broadcast-messsaction'.format(node) try: response = requests.post(url, json={ 'sender': sender, 'follower': follower, 'message': message, 'signature': signature }) if response.status_code == 400 or response.status_code == 500: print('Messsaction declined, needs resolving') return False except requests.exceptions.ConnectionError: continue return True return False
def add_messsaction(self, sender, recipient, signature, message, tag, amount, spread, is_recieving=False): """ Append a new value as well as the last blockchain value to the blockchain. Arguments: :sender: The sender of the coins. :recipient: The recipient of the coins. :amount: The amount of coins sent with the transaction (default = 1.0) """ #if self.hosting_node == None: # return False messsaction = Messsaction(sender, recipient, signature, message, tag, amount, spread) if Verification.verify_messsaction(messsaction, self.get_balance): self.__open_messsactions.append(messsaction) self.save_data() if not is_recieving: for node in self.__peer_nodes: url = "http://{}/broadcast-messsaction".format(node) try: response = requests.post(url, json={ 'sender': sender, 'recipient': recipient, 'message': message, 'tag': tag, 'amount': amount, 'spread': spread, 'signature': signature }) if response.status_code == 400 or response.status_code == 500: print("Messsaction declined, needs resolving") return False except requests.exceptions.ConnectionError: continue return True return False