Add required methods for decentralised consensus
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
import time
|
||||||
|
|
||||||
class Voter:
|
class Voter:
|
||||||
'''
|
'''
|
||||||
This class acts to replicate sensor information with the network to come to a consensus
|
This class acts to replicate sensor information with the network to come to a consensus
|
||||||
@@ -19,8 +22,21 @@ class Voter:
|
|||||||
on_vote: Callback to get the required vote to broadcast.
|
on_vote: Callback to get the required vote to broadcast.
|
||||||
'''
|
'''
|
||||||
self.on_vote = on_vote
|
self.on_vote = on_vote
|
||||||
|
self.client = mqtt.Client()
|
||||||
|
|
||||||
def submit_vote(self):
|
def submit_vote(self):
|
||||||
|
# Publish to swarm where all other voters will receive a vote.
|
||||||
|
|
||||||
|
|
||||||
|
# Wait a certain amount of time for responses, then fuse the information.
|
||||||
|
self.fuse_algorithm()
|
||||||
|
|
||||||
|
# Need the error and number of timestamps since voting started to finalise the consensus.
|
||||||
|
|
||||||
|
def fuse_algorithm(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def
|
def on_message(self, client, userdata, message):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user