-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5929d2
commit 309fc9e
Showing
15 changed files
with
1,034 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import asyncio | ||
from deccom.peers.peer import Peer | ||
from deccom.protocols.peerdiscovery import FixedPeers | ||
from deccom.protocols.defaultprotocol import DefaultProtocol | ||
from flowprotocol import FlowProtocol | ||
from deccom.nodes import Node | ||
|
||
|
||
|
||
def costmap(a1, a2): | ||
matrix = { | ||
"0": { | ||
"1": 1, | ||
"2": 1, | ||
"3": 10, | ||
"4": 10, | ||
"5": 10, | ||
"6": 10 | ||
}, | ||
"1": { | ||
"0": 1, | ||
"2": 10, | ||
"3": 1, | ||
"4": 3, | ||
"5": 10, | ||
"6": 10 | ||
}, | ||
"2": { | ||
"1": 10, | ||
"0": 1, | ||
"3": 2, | ||
"4": 1, | ||
"5": 10, | ||
"6": 10 | ||
}, | ||
"3": { | ||
"1": 1, | ||
"2": 2, | ||
"0": 10, | ||
"4": 10, | ||
"5": 10, | ||
"6": 1 | ||
}, | ||
"4": { | ||
"1": 3, | ||
"2": 1, | ||
"3": 10, | ||
"0": 10, | ||
"5": 10, | ||
"6": 1 | ||
}, | ||
"6": { | ||
"1": 10, | ||
"2": 10, | ||
"3": 1, | ||
"4": 1, | ||
"5": 10, | ||
"0": 10 | ||
}, | ||
} | ||
return matrix[a1][a2] | ||
peers = [Peer(("127.0.0.1", 10020), "0"), Peer(("127.0.0.1", 10023), "3"), Peer(("127.0.0.1", 10024), "4"), Peer(("127.0.0.1", 10022), "2")] | ||
Peer.me = Peer(("127.0.0.1", 10021), "1") | ||
lowest = DefaultProtocol() | ||
prs = FixedPeers(peers) | ||
prs.set_lower(lowest) | ||
fp = FlowProtocol(1, 3, 1, 0, 0, 0, costmap) | ||
fp.set_lower(prs) | ||
me = Node(fp,"127.0.0.1",10021, print) | ||
loop = asyncio.new_event_loop() | ||
loop.run_until_complete(me.listen()) | ||
loop.run_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import asyncio | ||
from deccom.peers.peer import Peer | ||
from deccom.protocols.peerdiscovery import FixedPeers | ||
from deccom.protocols.defaultprotocol import DefaultProtocol | ||
from flowprotocol import FlowProtocol | ||
from deccom.nodes import Node | ||
def costmap(a1, a2): | ||
matrix = { | ||
"0": { | ||
"1": 1, | ||
"2": 1, | ||
"3": 10, | ||
"4": 10, | ||
"5": 10, | ||
"6": 10 | ||
}, | ||
"1": { | ||
"0": 1, | ||
"2": 10, | ||
"3": 1, | ||
"4": 3, | ||
"5": 10, | ||
"6": 10 | ||
}, | ||
"2": { | ||
"1": 10, | ||
"0": 1, | ||
"3": 2, | ||
"4": 1, | ||
"5": 10, | ||
"6": 10 | ||
}, | ||
"3": { | ||
"1": 1, | ||
"2": 2, | ||
"0": 10, | ||
"4": 10, | ||
"5": 10, | ||
"6": 1 | ||
}, | ||
"4": { | ||
"1": 3, | ||
"2": 1, | ||
"3": 10, | ||
"0": 10, | ||
"5": 10, | ||
"6": 1 | ||
}, | ||
"6": { | ||
"1": 10, | ||
"2": 10, | ||
"3": 1, | ||
"4": 1, | ||
"5": 10, | ||
"0": 10 | ||
}, | ||
} | ||
return matrix[a1][a2] | ||
peers = [Peer(("127.0.0.1", 10021), "1"), Peer(("127.0.0.1", 10022), "2")] | ||
Peer.me = Peer(("127.0.0.1", 10020), "0") | ||
lowest = DefaultProtocol() | ||
prs = FixedPeers(peers) | ||
prs.set_lower(lowest) | ||
fp = FlowProtocol(0, 3, 4, 0, 0, 4, costmap) | ||
fp.set_lower(prs) | ||
me = Node(fp,"127.0.0.1",10020, print) | ||
loop = asyncio.new_event_loop() | ||
loop.run_until_complete(me.listen()) | ||
loop.run_forever() |
Oops, something went wrong.