Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vincent Pelletier
neoppod
Commits
3a14526f
Commit
3a14526f
authored
May 21, 2024
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQUASH Use MAX_TID as stand-in for "no known First TID"
This simplifies the code a lot.
parent
08ce5273
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
23 deletions
+16
-23
neo/master/handlers/administration.py
neo/master/handlers/administration.py
+1
-2
neo/master/transactions.py
neo/master/transactions.py
+3
-4
neo/storage/database/manager.py
neo/storage/database/manager.py
+2
-8
neo/storage/database/mysql.py
neo/storage/database/mysql.py
+2
-1
neo/storage/database/sqlite.py
neo/storage/database/sqlite.py
+6
-6
neo/tests/protocol
neo/tests/protocol
+1
-1
neo/tests/storage/testStorageDBTests.py
neo/tests/storage/testStorageDBTests.py
+1
-1
No files found.
neo/master/handlers/administration.py
View file @
3a14526f
...
@@ -239,8 +239,7 @@ class AdministrationHandler(MasterHandler):
...
@@ -239,8 +239,7 @@ class AdministrationHandler(MasterHandler):
app
=
self
.
app
app
=
self
.
app
if
app
.
getLastTransaction
()
<=
tid
:
if
app
.
getLastTransaction
()
<=
tid
:
raise
AnswerDenied
(
"Truncating after last transaction does nothing"
)
raise
AnswerDenied
(
"Truncating after last transaction does nothing"
)
first_tid
=
app
.
tm
.
getFirstTID
()
if
app
.
tm
.
getFirstTID
()
>
tid
:
if
first_tid
is
None
or
first_tid
>
tid
:
raise
AnswerDenied
(
"Truncating before first transaction is "
raise
AnswerDenied
(
"Truncating before first transaction is "
"probably not what you intended to do"
)
"probably not what you intended to do"
)
if
app
.
pm
.
getApprovedRejected
(
add64
(
tid
,
1
))[
0
]:
if
app
.
pm
.
getApprovedRejected
(
add64
(
tid
,
1
))[
0
]:
...
...
neo/master/transactions.py
View file @
3a14526f
...
@@ -20,7 +20,7 @@ from struct import pack, unpack
...
@@ -20,7 +20,7 @@ from struct import pack, unpack
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.exception
import
ProtocolError
from
neo.lib.exception
import
ProtocolError
from
neo.lib.handler
import
DelayEvent
,
EventQueue
from
neo.lib.handler
import
DelayEvent
,
EventQueue
from
neo.lib.protocol
import
uuid_str
,
ZERO_OID
,
ZERO_TID
from
neo.lib.protocol
import
uuid_str
,
ZERO_OID
,
ZERO_TID
,
MAX_TID
from
neo.lib.util
import
dump
,
u64
,
addTID
,
tidFromTime
from
neo.lib.util
import
dump
,
u64
,
addTID
,
tidFromTime
class
Transaction
(
object
):
class
Transaction
(
object
):
...
@@ -179,7 +179,7 @@ class TransactionManager(EventQueue):
...
@@ -179,7 +179,7 @@ class TransactionManager(EventQueue):
self
.
_ttid_dict
=
{}
self
.
_ttid_dict
=
{}
self
.
_last_oid
=
ZERO_OID
self
.
_last_oid
=
ZERO_OID
self
.
_last_tid
=
ZERO_TID
self
.
_last_tid
=
ZERO_TID
self
.
_first_tid
=
None
self
.
_first_tid
=
MAX_TID
self
.
_unlockPending
=
self
.
_firstUnlockPending
self
.
_unlockPending
=
self
.
_firstUnlockPending
# queue filled with ttids pointing to transactions with increasing tids
# queue filled with ttids pointing to transactions with increasing tids
self
.
_queue
=
deque
()
self
.
_queue
=
deque
()
...
@@ -215,8 +215,7 @@ class TransactionManager(EventQueue):
...
@@ -215,8 +215,7 @@ class TransactionManager(EventQueue):
return
oid_list
return
oid_list
def
setFirstTID
(
self
,
tid
):
def
setFirstTID
(
self
,
tid
):
first_tid
=
self
.
_first_tid
if
self
.
_first_tid
>
tid
:
if
tid
is
not
None
and
(
first_tid
is
None
or
first_tid
>
tid
):
self
.
_first_tid
=
tid
self
.
_first_tid
=
tid
def
getFirstTID
(
self
):
def
getFirstTID
(
self
):
...
...
neo/storage/database/manager.py
View file @
3a14526f
...
@@ -770,14 +770,8 @@ class DatabaseManager(object):
...
@@ -770,14 +770,8 @@ class DatabaseManager(object):
"""
"""
x
=
self
.
_readable_set
x
=
self
.
_readable_set
if
x
:
if
x
:
getFirstTID
=
self
.
_getFirstTID
return
util
.
p64
(
min
(
map
(
self
.
_getFirstTID
,
x
)))
min_tid
=
None
return
MAX_TID
for
partition
in
x
:
tid
=
getFirstTID
(
partition
)
if
tid
is
not
None
and
(
min_tid
is
None
or
tid
<
min_tid
):
min_tid
=
tid
if
min_tid
is
not
None
:
return
util
.
p64
(
min_tid
)
def
_getLastTID
(
self
,
partition
,
max_tid
=
None
):
def
_getLastTID
(
self
,
partition
,
max_tid
=
None
):
"""Return tid of last transaction <= 'max_tid' in given 'partition'
"""Return tid of last transaction <= 'max_tid' in given 'partition'
...
...
neo/storage/database/mysql.py
View file @
3a14526f
...
@@ -53,7 +53,7 @@ from .manager import MVCCDatabaseManager, splitOIDField
...
@@ -53,7 +53,7 @@ from .manager import MVCCDatabaseManager, splitOIDField
from
neo.lib
import
logging
,
util
from
neo.lib
import
logging
,
util
from
neo.lib.exception
import
NonReadableCell
,
UndoPackError
from
neo.lib.exception
import
NonReadableCell
,
UndoPackError
from
neo.lib.interfaces
import
implements
from
neo.lib.interfaces
import
implements
from
neo.lib.protocol
import
CellStates
,
ZERO_OID
,
ZERO_TID
,
ZERO_HASH
from
neo.lib.protocol
import
CellStates
,
ZERO_OID
,
ZERO_TID
,
ZERO_HASH
,
MAX_TID
class
MysqlError
(
DatabaseFailure
):
class
MysqlError
(
DatabaseFailure
):
...
@@ -464,6 +464,7 @@ class MySQLDatabaseManager(MVCCDatabaseManager):
...
@@ -464,6 +464,7 @@ class MySQLDatabaseManager(MVCCDatabaseManager):
if
tid_list
:
if
tid_list
:
(
tid
,
),
=
tid_list
(
tid
,
),
=
tid_list
return
tid
return
tid
return
util
.
u64
(
MAX_TID
)
def
_getLastTID
(
self
,
partition
,
max_tid
=
None
):
def
_getLastTID
(
self
,
partition
,
max_tid
=
None
):
x
=
"WHERE `partition`=%s"
%
partition
x
=
"WHERE `partition`=%s"
%
partition
...
...
neo/storage/database/sqlite.py
View file @
3a14526f
...
@@ -28,7 +28,7 @@ from .manager import DatabaseManager, splitOIDField
...
@@ -28,7 +28,7 @@ from .manager import DatabaseManager, splitOIDField
from
neo.lib
import
logging
,
util
from
neo.lib
import
logging
,
util
from
neo.lib.exception
import
NonReadableCell
,
UndoPackError
from
neo.lib.exception
import
NonReadableCell
,
UndoPackError
from
neo.lib.interfaces
import
implements
from
neo.lib.interfaces
import
implements
from
neo.lib.protocol
import
CellStates
,
ZERO_OID
,
ZERO_TID
,
ZERO_HASH
from
neo.lib.protocol
import
CellStates
,
ZERO_OID
,
ZERO_TID
,
ZERO_HASH
,
MAX_TID
def
unique_constraint_message
(
table
,
*
columns
):
def
unique_constraint_message
(
table
,
*
columns
):
c
=
sqlite3
.
connect
(
":memory:"
)
c
=
sqlite3
.
connect
(
":memory:"
)
...
@@ -344,11 +344,11 @@ class SQLiteDatabaseManager(DatabaseManager):
...
@@ -344,11 +344,11 @@ class SQLiteDatabaseManager(DatabaseManager):
return
self
.
query
(
"SELECT * FROM pt"
)
return
self
.
query
(
"SELECT * FROM pt"
)
def
_getFirstTID
(
self
,
partition
):
def
_getFirstTID
(
self
,
partition
):
try
:
tid
=
self
.
query
(
"SELECT MIN(tid) FROM trans WHERE partition=?"
,
return
self
.
query
(
"SELECT MIN(tid) FROM trans WHERE partition=?"
,
(
partition
,)).
fetchone
()[
0
]
(
partition
,)).
fetchone
()[
0
]
except
TypeError
:
if
tid
is
None
:
pass
return
util
.
u64
(
MAX_TID
)
return
tid
def
_getLastTID
(
self
,
partition
,
max_tid
=
None
):
def
_getLastTID
(
self
,
partition
,
max_tid
=
None
):
x
=
self
.
query
x
=
self
.
query
...
...
neo/tests/protocol
View file @
3a14526f
...
@@ -13,7 +13,7 @@ AnswerFetchObjects(?p64,?p64,{:})
...
@@ -13,7 +13,7 @@ AnswerFetchObjects(?p64,?p64,{:})
AnswerFetchTransactions(?p64,[],?p64)
AnswerFetchTransactions(?p64,[],?p64)
AnswerFinalTID(p64)
AnswerFinalTID(p64)
AnswerInformationLocked(p64)
AnswerInformationLocked(p64)
AnswerLastIDs(?p64,?p64,
?
p64)
AnswerLastIDs(?p64,?p64,p64)
AnswerLastTransaction(p64)
AnswerLastTransaction(p64)
AnswerLockedTransactions({p64:?p64})
AnswerLockedTransactions({p64:?p64})
AnswerMonitorInformation([?bin],[?bin],bin)
AnswerMonitorInformation([?bin],[?bin],bin)
...
...
neo/tests/storage/testStorageDBTests.py
View file @
3a14526f
...
@@ -183,7 +183,7 @@ class StorageDBTests(NeoUnitTestBase):
...
@@ -183,7 +183,7 @@ class StorageDBTests(NeoUnitTestBase):
txn1
,
objs1
=
self
.
getTransaction
([
oid1
])
txn1
,
objs1
=
self
.
getTransaction
([
oid1
])
txn2
,
objs2
=
self
.
getTransaction
([
oid2
])
txn2
,
objs2
=
self
.
getTransaction
([
oid2
])
# nothing in database
# nothing in database
self
.
assertEqual
(
self
.
db
.
getFirstTID
(),
None
)
self
.
assertEqual
(
self
.
db
.
getFirstTID
(),
MAX_TID
)
self
.
assertEqual
(
self
.
db
.
getLastIDs
(),
(
None
,
None
))
self
.
assertEqual
(
self
.
db
.
getLastIDs
(),
(
None
,
None
))
self
.
assertEqual
(
self
.
db
.
getUnfinishedTIDDict
(),
{})
self
.
assertEqual
(
self
.
db
.
getUnfinishedTIDDict
(),
{})
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
None
)
...
...
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