Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ece428mp1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
azukor2
ece428mp1
Commits
c9f393b8
Commit
c9f393b8
authored
3 years ago
by
Jeffrey Zhang
Browse files
Options
Downloads
Patches
Plain Diff
Fix typo bugs
parent
fbeea14b
No related branches found
No related tags found
1 merge request
!1
Fix typos
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
MessageServer.py
+1
-1
1 addition, 1 deletion
MessageServer.py
TransactionDeliverer.py
+5
-5
5 additions, 5 deletions
TransactionDeliverer.py
main.py
+2
-2
2 additions, 2 deletions
main.py
node.config
+2
-2
2 additions, 2 deletions
node.config
with
10 additions
and
10 deletions
MessageServer.py
+
1
−
1
View file @
c9f393b8
...
...
@@ -33,7 +33,7 @@ class MyTCPHandler(socketserver.BaseRequestHandler):
obj
.
receive_action
(
td
)
td
.
received_messages
.
add
(
obj
.
message_id
)
reliable_multicast_messages
=
{
client_name
:
replace
(
obj
,
receiver
=
client_name
)
for
client_name
in
td
.
client_sockets
reliable_multicast_messages
=
{
client_name
:
replace
(
obj
,
receiver
=
client_name
)
for
client_name
in
td
.
client_sockets
.
keys
()
if
client_name
!=
self
.
client_name
and
client_name
!=
td
.
node_name
}
...
...
This diff is collapsed.
Click to expand it.
TransactionDeliverer.py
+
5
−
5
View file @
c9f393b8
...
...
@@ -52,7 +52,7 @@ class TransactionDeliverer:
def
new_transaction_message
(
self
,
transaction
:
Transaction
):
# Receives a transaction and builds the message to be sending out to all other nodes
print
(
"
Sending message
"
)
transaction_message
=
TransactionMessage
(
self
.
node_name
,
self
.
node_name
,
str
(
uuid4
()),
transaction
,
False
)
transaction_message
=
TransactionMessage
(
self
.
node_name
,
self
.
node_name
,
transaction
,
str
(
uuid4
())
,
False
)
# ISIS - propose a priority higher than those the node has already proposed or seen
proposed_priority
=
self
.
next_priority
...
...
@@ -64,7 +64,7 @@ class TransactionDeliverer:
self
.
transactions_id_map
[
transaction_message
.
transaction_ID
]
=
queue_item
transaction_messages
=
{
client_name
:
replace
(
transaction_message
,
receiver
=
client_name
)
for
client_name
in
self
.
client_sockets
.
item
s
()
for
client_name
in
self
.
client_sockets
.
key
s
()
}
self
.
multicast
(
transaction_messages
)
...
...
@@ -74,14 +74,14 @@ class TransactionDeliverer:
self
.
client_sockets
[
transaction_message
.
sender
].
sendall
(
pickle
.
dumps
(
ProposedPriorityMessage
(
self
.
node_name
,
transaction_message
.
sender
,
transaction_message
.
id
,
proposed_priority
)
ProposedPriorityMessage
(
self
.
node_name
,
transaction_message
.
sender
,
transaction_message
.
transaction_ID
,
proposed_priority
)
)
)
queue_item
=
_Transaction_Message_Queue_Item
(
proposed_priority
,
self
.
node_name
,
transaction_message
,
1
)
self
.
transactions_queue
.
append
(
queue_item
)
self
.
transactions_queue
.
sort
()
self
.
transactions_id_map
[
transaction_message
.
id
]
=
queue_item
self
.
transactions_id_map
[
transaction_message
.
transaction_ID
]
=
queue_item
def
process_proposed_priority_message
(
self
,
proposed_priority_message
:
ProposedPriorityMessage
):
queue_item
=
self
.
transactions_id_map
[
proposed_priority_message
.
transaction_ID
]
...
...
@@ -96,7 +96,7 @@ class TransactionDeliverer:
agreed_priority_message
=
AgreedPriorityMessage
(
self
.
node_name
,
self
.
node_name
,
proposed_priority_message
.
transaction_ID
,
queue_item
.
priority
)
agreed_priority_messages
=
{
client_name
:
replace
(
agreed_priority_messages
,
receiver
=
client_name
)
for
client_name
in
self
.
client_sockets
for
client_name
in
self
.
client_sockets
.
keys
()
}
self
.
multicast
(
agreed_priority_messages
)
...
...
This diff is collapsed.
Click to expand it.
main.py
+
2
−
2
View file @
c9f393b8
...
...
@@ -42,9 +42,9 @@ def process_inputs(td: TransactionDeliverer):
for
line
in
sys
.
stdin
:
line
=
line
.
split
(
'
'
)
if
line
[
0
]
==
"
DEPOSIT
"
:
transaction
=
Transaction
(
TransactionType
.
DEPOSIT
,
line
[
2
],
line
[
1
])
transaction
=
Transaction
(
TransactionType
.
DEPOSIT
,
int
(
line
[
2
]
.
strip
())
,
line
[
1
])
elif
line
[
0
]
==
"
TRANSFER
"
:
transaction
=
Transaction
(
TransactionType
.
TRANSFER
,
line
[
4
],
line
[
3
],
line
[
1
])
transaction
=
Transaction
(
TransactionType
.
TRANSFER
,
int
(
line
[
4
]
.
strip
())
,
line
[
3
],
line
[
1
])
else
:
# Should never happen!
raise
NotImplementedError
(
"
Unknown command
"
)
...
...
This diff is collapsed.
Click to expand it.
node.config
+
2
−
2
View file @
c9f393b8
2
node1
localhost
4285
node2
localhost
4286
\ No newline at end of file
node1
localhost
4281
node2
localhost
4282
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment