Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
algorand
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nilak
algorand
Commits
61c972d3
Commit
61c972d3
authored
Apr 28, 2019
by
THAKARE AKSHAY HARIBHAU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
step 1.5.6 : Block proposal sent out and receveid by others
parent
5dc86966
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
5 deletions
+32
-5
Config.py
Config.py
+3
-0
Node.py
Node.py
+4
-0
OverlayNode.py
OverlayNode.py
+24
-4
TimeSimulator.py
TimeSimulator.py
+1
-1
No files found.
Config.py
0 → 100644
View file @
61c972d3
lambda_proposer
=
3
# wait time for priority messages to be received
tou_proposer
=
20
# proposer rolecount
ROLE_BLOCK_PROPOSER
=
'BLOCK_PROPOSER'
\ No newline at end of file
Node.py
View file @
61c972d3
...
...
@@ -110,6 +110,10 @@ class Node(SystemEntity):
for
ResumeTask
in
ResumeTasks
:
command
=
self
.
commands
.
get
(
ResumeTask
[
0
])
ResumeOut
=
command
(
time
,
ResumeTask
[
1
:])
'''
synatx for proper return commands
yield "resume",timeafter_which_to_resume
'''
if
ResumeOut
and
ResumeOut
[
0
]
==
"resume"
:
self
.
logger
.
info
(
"resume has been called"
)
self
.
ResumeTasks
[
str
(
int
(
time
)
+
int
(
ResumeOut
[
1
]))]
.
append
((
"nextOn"
,
self
.
startNodeLifeCycleGenerator
,))
...
...
OverlayNode.py
View file @
61c972d3
...
...
@@ -2,6 +2,8 @@ from Node import Node
import
logging
import
Utility
import
hashlib
import
Config
import
random
genesisBlock
=
(
"I am the first block"
)
#
...
...
@@ -43,9 +45,10 @@ class OverlayNode(Node):
# Checking if I am a Block Propser
previousHash
=
hashlib
.
sha256
(
self
.
blockchain
[
-
1
]
.
encode
(
'utf-8'
))
.
hexdigest
()
seed
=
(
previousHash
,
self
.
currentRound
,
0
)
hash
,
proof
,
j
=
Utility
.
sortition
(
self
.
sk
,
seed
,
20
,
'BLOCK_PROPOSER'
,
self
.
weight
,
self
.
network
.
badaW
,
self
.
pk
)
hash
,
proof
,
j
=
Utility
.
sortition
(
self
.
sk
,
seed
,
Config
.
tou_proposer
,
Config
.
ROLE_BLOCK_PROPOSER
,
self
.
weight
,
self
.
network
.
badaW
,
self
.
pk
)
print
(
"I am the mighty J ="
,
j
)
if
j
>
0
:
if
j
>
0
:
# only the block proposer commity mebers can enter here
min_sha_priority
=
None
# min_sub_user_index = None
# msg_to_broadcast = ( currentRound, hash , min_sub_user_index , min_sha_priority )
...
...
@@ -65,8 +68,25 @@ class OverlayNode(Node):
self
.
logger
.
info
(
"broadcsting priority message : "
+
str
(
priority_msg_to_broadcast
))
self
.
broadcast
(
self
.
network
.
time
,
priority_msg_to_broadcast
)
print
(
"i am before yield 1"
,
self
.
id
)
yield
"resume"
,
7
self
.
logger
.
info
(
"WAITING FOR PRIORITY MESSAGES from others"
)
yield
"resume"
,
Config
.
lambda_proposer
greater_flag
=
True
for
priority_msg_other
in
self
.
uniqueReceivedMessages
:
if
min_sha_priority
>
priority_msg_other
[
4
]:
greater_flag
=
False
if
greater_flag
:
self
.
logger
.
info
(
"I am the block proposer"
)
'''
BLOCK_PROPOSAL_MSG_to_broadcast : ("BLOCK_PROPOSAL_MSG", previousblockhash,A random string as txns,Nod`s priority payload)
'''
BLOCK_PROPOSAL_MSG_to_broadcast
=
(
"BLOCK_PROPOSAL_MSG"
,
previousHash
,
Utility
.
pseudoRandomGenerator
(
random
.
randint
(
0
,
1000
)),
priority_msg_to_broadcast
[
1
:])
self
.
logger
.
info
(
"broadcsting BLOCK Proposal Message : "
+
str
(
BLOCK_PROPOSAL_MSG_to_broadcast
))
self
.
broadcast
(
self
.
network
.
time
,
BLOCK_PROPOSAL_MSG_to_broadcast
)
yield
"resume"
,
9
self
.
logger
.
info
(
self
.
uniqueReceivedMessages
)
yield
"resume"
,
40
...
...
TimeSimulator.py
View file @
61c972d3
...
...
@@ -12,7 +12,7 @@ class TimeSimulator(object):
return
"Time : "
+
str
(
self
.
_systemTime
)
def
startTicking
(
self
,
callback
):
for
i
in
range
(
1
5
):
for
i
in
range
(
2
5
):
self
.
_systemTime
=
self
.
_systemTime
+
1
logger
.
info
(
self
)
callback
(
str
(
self
.
_systemTime
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment