Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycfhelpers
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
cellframe
python-cellframe-modules
pycfhelpers
Commits
d513d6b6
Commit
d513d6b6
authored
1 year ago
by
Dmitry Puzyrkov
Browse files
Options
Downloads
Patches
Plain Diff
[+] bridge bugfixes
parent
8c636a6e
No related branches found
No related tags found
1 merge request
!6
Feature 10361
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
node/datums.py
+25
-14
25 additions, 14 deletions
node/datums.py
node/net.py
+9
-7
9 additions, 7 deletions
node/net.py
with
34 additions
and
21 deletions
node/datums.py
+
25
−
14
View file @
d513d6b6
...
...
@@ -47,12 +47,16 @@ class CFDatum:
def
serialize
(
self
)
->
bytes
:
return
self
.
_origin_datum
.
raw
def
__repr__
(
self
):
return
f
"
{
self
.
type
}
:
{
self
.
hash
}
"
class
SubDatum
:
class
CFSubDatum
:
def
__init__
(
self
,
parent_datum
:
CFDatum
,
sub_datum
:
DatumTx
|
DatumToken
|
DatumEmission
|
DatumDecree
|
DatumAnchor
|
bytes
):
self
.
_parent_datum
=
parent_datum
self
.
_origin_sub_datum
=
sub_datum
self
.
hash
=
str
(
sub_datum
.
hash
)
self
.
type
=
"
DEFAULT
"
if
sub_datum
is
None
:
self
.
hash
=
parent_datum
.
hash
...
...
@@ -69,12 +73,12 @@ class SubDatum:
T
=
TypeVar
(
'
T
'
,
bound
=
CFItem
)
class
CFDatumTX
(
SubDatum
):
class
CFDatumTX
(
CF
SubDatum
):
def
__init__
(
self
,
parent_datum
:
CFDatum
,
sub_datum
:
DatumTx
):
super
().
__init__
(
parent_datum
,
sub_datum
)
if
self
.
type
==
"
CORRUPTED
"
:
return
self
.
hash
=
str
(
sub_datum
.
hash
)
self
.
created_at
=
sub_datum
.
dateCreated
ledger
=
self
.
net
.
get_ledger
()
self
.
ticker
=
ledger
.
get_tx_ticker
(
self
)
...
...
@@ -96,7 +100,7 @@ class CFDatumTX(SubDatum):
return
all_items
class
CFDatumToken
(
SubDatum
):
class
CFDatumToken
(
CF
SubDatum
):
def
__init__
(
self
,
parent_datum
:
CFDatum
,
sub_datum
:
DatumToken
):
super
().
__init__
(
parent_datum
,
sub_datum
)
if
self
.
type
==
"
CORRUPTED
"
:
...
...
@@ -109,13 +113,12 @@ class CFDatumToken(SubDatum):
except
AttributeError
as
e
:
self
.
signs
=
[]
class
CFDatumEmission
(
SubDatum
):
class
CFDatumEmission
(
CFSubDatum
):
def
__init__
(
self
,
parent_datum
:
CFDatum
,
sub_datum
:
DatumEmission
):
super
().
__init__
(
parent_datum
,
sub_datum
)
if
self
.
type
==
"
CORRUPTED
"
:
return
self
.
hash
=
str
(
sub_datum
.
hash
)
self
.
version
=
sub_datum
.
version
self
.
type
=
sub_datum
.
typeStr
self
.
ticker
=
sub_datum
.
ticker
...
...
@@ -126,7 +129,7 @@ class CFDatumEmission(SubDatum):
self
.
data
=
[
CFSign
(
sign
,
self
.
net
)
for
sign
in
sub_datum
.
signs
]
else
:
self
.
data
=
sub_datum
.
data
self
.
signs
=
[
CFSign
(
sign
,
self
.
net
)
for
sign
in
sub_datum
.
signs
]
self
.
tsd
=
{}
for
tsd_type
in
TSD
:
tsd
=
self
.
_origin_sub_datum
.
getTSD
(
tsd_type
.
value
)
...
...
@@ -148,39 +151,47 @@ class CFDatumEmission(SubDatum):
self
.
tsd
[
tsd_type
.
name
]
=
tsd_data
@property
def
signs
(
self
)
->
list
[
CFSign
]:
return
[
CFSign
(
sign
,
self
.
net
)
for
sign
in
self
.
_origin_sub_datum
.
signs
]
def
__repr__
(
self
):
return
f
"
{
self
.
type
}
:
{
self
.
hash
}
"
@property
def
valid_sign_hashes
(
self
)
->
list
[
str
]:
token_auth_signs_pkey_hashes
=
self
.
net
.
get_ledger
().
token_auth_signs_pkey_hashes
(
self
.
_parent_datum
)
return
[
sign
.
pkey_hash
for
sign
in
self
.
signs
if
sign
.
pkey_hash
in
token_auth_signs_pkey_hashes
]
def
add_sign
(
self
,
certificate
:
CFCertificate
)
->
None
:
def
add_sign
(
self
,
certificate
:
CFCertificate
)
->
str
:
self
.
_origin_sub_datum
.
addSign
(
certificate
.
_origin_certificate
)
return
self
.
signs
[
-
1
]
class
CFDatumDecree
(
SubDatum
):
class
CFDatumDecree
(
CF
SubDatum
):
def
__init__
(
self
,
parent_datum
:
CFDatum
,
sub_datum
:
DatumDecree
):
super
().
__init__
(
parent_datum
,
sub_datum
)
if
self
.
type
==
"
CORRUPTED
"
:
return
self
.
hash
=
str
(
sub_datum
.
hash
)
self
.
created_at
=
sub_datum
.
tsCreated
self
.
type
=
sub_datum
.
typeStr
self
.
subtype
=
sub_datum
.
subtypeStr
self
.
signs
=
[
CFSign
(
sign
,
self
.
net
)
for
sign
in
sub_datum
.
signs
]
class
CFDatumAnchor
(
SubDatum
):
class
CFDatumAnchor
(
CF
SubDatum
):
def
__init__
(
self
,
parent_datum
:
CFDatum
,
sub_datum
:
DatumAnchor
):
super
().
__init__
(
parent_datum
,
sub_datum
)
if
self
.
type
==
"
CORRUPTED
"
:
return
self
.
hash
=
str
(
sub_datum
.
hash
)
self
.
created_at
=
sub_datum
.
created
self
.
signs
=
[
CFSign
(
sign
,
self
.
net
)
for
sign
in
sub_datum
.
signs
]
class
CFDatumCustom
(
SubDatum
):
class
CFDatumCustom
(
CF
SubDatum
):
"""
get data from dataRaw()
"""
...
...
This diff is collapsed.
Click to expand it.
node/net.py
+
9
−
7
View file @
d513d6b6
...
...
@@ -8,7 +8,7 @@ from CellFrame.Network import Net
from
CellFrame.Chain
import
ChainAtomPtr
,
Ledger
,
ChainAddr
,
Mempool
from
.consensus
import
CFEvent
,
CFBlock
from
.datums
import
CFDatum
,
CFDatumTX
,
CFDatumEmission
from
.datums
import
CFDatum
,
CFSubDatum
,
CFDatumTX
,
CFDatumEmission
from
.types
import
CFNetState
,
ticker
,
ledger_cache_rc
from
..common.types
import
ChainTypes
from
dataclasses
import
dataclass
...
...
@@ -129,10 +129,12 @@ class CFChain:
def
callback_wrapper
(
op_code
,
group
,
key
,
value
,
*
other
):
try
:
mempool
=
CFMempool
(
self
)
datum
=
mempool
.
get_datum_from_bytes
(
value
)
if
datum
is
None
:
raise
ValueError
(
f
"
Can
'
t extract Datum from Mempool key=
{
key
}
"
)
log
.
message
(
f
"
Mempool callback:
{
datum
.
hash
=
}
|
{
key
=
}
|
{
op_code
=
}
"
)
if
value
:
datum
=
mempool
.
get_datum_from_bytes
(
value
)
else
:
datum
=
key
log
.
message
(
f
"
Mempool callback:
{
op_code
=
}
{
key
=
}
{
datum
=
}
"
)
callback
(
op_code
,
datum
,
*
args
,
chain
=
self
,
**
kwargs
)
except
Exception
:
log
.
error
(
f
"
Error =
{
traceback
.
format_exc
()
}
"
)
...
...
@@ -241,5 +243,5 @@ class CFMempool:
def
reason
(
self
):
pass
def
remove
(
self
,
emission
:
CFDatum
Emission
)
->
bool
:
return
Mempool
.
remove
(
self
.
chain
.
_origin_chain
,
emission
.
hash
)
def
remove
(
self
,
datum
:
CFDatum
|
CFSubDatum
)
->
bool
:
return
Mempool
.
remove
(
self
.
chain
.
_origin_chain
,
datum
.
hash
)
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