Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
3e226350
Commit
3e226350
authored
Jan 04, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: optimize generation of new oids
parent
edefaca7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
neo/client/app.py
neo/client/app.py
+6
-6
neo/client/handlers/master.py
neo/client/handlers/master.py
+1
-0
neo/tests/client/testMasterHandler.py
neo/tests/client/testMasterHandler.py
+1
-1
No files found.
neo/client/app.py
View file @
3e226350
...
...
@@ -80,7 +80,7 @@ class Application(object):
self
.
uuid
=
None
self
.
_cache
=
ClientCache
()
self
.
_loading_oid
=
None
self
.
new_oid_list
=
[]
self
.
new_oid_list
=
()
self
.
last_oid
=
'
\
0
'
*
8
self
.
last_tid
=
None
self
.
storage_event_handler
=
storage
.
StorageEventHandler
(
self
)
...
...
@@ -246,7 +246,7 @@ class Application(object):
with
self
.
_connecting_to_master_node
:
result
=
self
.
master_conn
if
result
is
None
:
self
.
new_oid_list
=
[]
self
.
new_oid_list
=
()
result
=
self
.
master_conn
=
self
.
_connectToPrimaryNode
()
return
result
...
...
@@ -324,16 +324,16 @@ class Application(object):
"""Get a new OID."""
self
.
_oid_lock_acquire
()
try
:
if
len
(
self
.
new_oid_list
)
==
0
:
if
not
self
.
new_oid_list
:
# Get new oid list from master node
# we manage a list of oid here to prevent
# from asking too many time new oid one by one
# from master node
self
.
_askPrimary
(
Packets
.
AskNewOIDs
(
100
))
if
len
(
self
.
new_oid_list
)
<=
0
:
if
not
self
.
new_oid_list
:
raise
NEOStorageError
(
'new_oid failed'
)
self
.
last_oid
=
self
.
new_oid_list
.
pop
(
0
)
return
self
.
last_
oid
self
.
last_oid
=
oid
=
self
.
new_oid_list
.
pop
(
)
return
oid
finally
:
self
.
_oid_lock_release
()
...
...
neo/client/handlers/master.py
View file @
3e226350
...
...
@@ -189,6 +189,7 @@ class PrimaryAnswersHandler(AnswerBaseHandler):
self
.
app
.
setHandlerData
(
ttid
)
def
answerNewOIDs
(
self
,
conn
,
oid_list
):
oid_list
.
reverse
()
self
.
app
.
new_oid_list
=
oid_list
def
answerTransactionFinished
(
self
,
conn
,
_
,
tid
):
...
...
neo/tests/client/testMasterHandler.py
View file @
3e226350
...
...
@@ -168,7 +168,7 @@ class MasterAnswersHandlerTests(MasterHandlerTests):
conn
=
self
.
getFakeConnection
()
oid1
,
oid2
,
oid3
=
self
.
getOID
(
0
),
self
.
getOID
(
1
),
self
.
getOID
(
2
)
self
.
handler
.
answerNewOIDs
(
conn
,
[
oid1
,
oid2
,
oid3
])
self
.
assertEqual
(
self
.
app
.
new_oid_list
,
[
oid
1
,
oid2
,
oid3
])
self
.
assertEqual
(
self
.
app
.
new_oid_list
,
[
oid
3
,
oid2
,
oid1
])
def
test_answerTransactionFinished
(
self
):
conn
=
self
.
getFakeConnection
()
...
...
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