Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hivemind
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
hive
hivemind
Commits
ac5010b8
Commit
ac5010b8
authored
4 years ago
by
Mariusz Trela
Committed by
Mariusz Trela
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Avoiding a redundant loop during `effective_comment_vote_operation` processing
parent
3bd73fbc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
5 merge requests
!456
Release candidate v1 24
,
!230
Setup monitoring with pghero
,
!138
Small typos fixed
,
!135
Enable postgres monitoring on CI server
,
!116
Avoiding a redundant loop during `effective_comment_vote_operation` processing
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hive/indexer/blocks.py
+4
-12
4 additions, 12 deletions
hive/indexer/blocks.py
hive/indexer/votes.py
+18
-13
18 additions, 13 deletions
hive/indexer/votes.py
with
22 additions
and
25 deletions
hive/indexer/blocks.py
+
4
−
12
View file @
ac5010b8
...
...
@@ -116,8 +116,6 @@ class Blocks:
@staticmethod
def
prepare_vops
(
comment_payout_ops
,
vopsList
,
date
,
block_num
):
vote_ops
=
{}
ineffective_deleted_ops
=
{}
registered_ops_stats
=
[
'
author_reward_operation
'
,
'
comment_reward_operation
'
,
'
effective_comment_vote_operation
'
,
'
comment_payout_update_operation
'
,
'
ineffective_delete_comment_operation
'
]
...
...
@@ -146,8 +144,7 @@ class Blocks:
comment_payout_ops
[
key
][
op_type
]
=
(
op_value
,
date
)
elif
op_type
==
'
effective_comment_vote_operation
'
:
key_vote
=
"
{}/{}/{}
"
.
format
(
op_value
[
'
voter
'
],
op_value
[
'
author
'
],
op_value
[
'
permlink
'
])
vote_ops
[
key_vote
]
=
op_value
Votes
.
effective_comment_vote_op
(
op_value
)
if
key
not
in
comment_payout_ops
:
comment_payout_ops
[
key
]
=
{
'
author_reward_operation
'
:
None
,
'
comment_reward_operation
'
:
None
,
'
effective_comment_vote_operation
'
:
None
,
'
comment_payout_update_operation
'
:
None
}
...
...
@@ -166,7 +163,7 @@ class Blocks:
if
op_type
in
registered_ops_stats
:
OPSM
.
op_stats
(
op_type
,
OPSM
.
stop
(
start
))
return
(
vote_ops
,
ineffective_deleted_ops
)
return
ineffective_deleted_ops
@classmethod
...
...
@@ -184,16 +181,15 @@ class Blocks:
if
cls
.
_head_block_date
is
None
:
cls
.
_head_block_date
=
cls
.
_current_block_date
vote_ops
=
None
comment_payout_stats
=
None
ineffective_deleted_ops
=
None
if
is_initial_sync
:
if
num
in
virtual_operations
:
(
vote_ops
,
ineffective_deleted_ops
)
=
Blocks
.
prepare_vops
(
Posts
.
comment_payout_ops
,
virtual_operations
[
num
],
cls
.
_current_block_date
,
num
)
ineffective_deleted_ops
=
Blocks
.
prepare_vops
(
Posts
.
comment_payout_ops
,
virtual_operations
[
num
],
cls
.
_current_block_date
,
num
)
else
:
vops
=
hived
.
get_virtual_operations
(
num
)
(
vote_ops
,
ineffective_deleted_ops
)
=
Blocks
.
prepare_vops
(
Posts
.
comment_payout_ops
,
vops
,
cls
.
_current_block_date
,
num
)
ineffective_deleted_ops
=
Blocks
.
prepare_vops
(
Posts
.
comment_payout_ops
,
vops
,
cls
.
_current_block_date
,
num
)
json_ops
=
[]
for
tx_idx
,
tx
in
enumerate
(
block
[
'
transactions
'
]):
...
...
@@ -258,10 +254,6 @@ class Blocks:
if
json_ops
:
CustomOp
.
process_ops
(
json_ops
,
num
,
cls
.
_head_block_date
)
if
vote_ops
is
not
None
:
for
k
,
v
in
vote_ops
.
items
():
Votes
.
effective_comment_vote_op
(
k
,
v
)
cls
.
_head_block_date
=
cls
.
_current_block_date
return
num
...
...
This diff is collapsed.
Click to expand it.
hive/indexer/votes.py
+
18
−
13
View file @
ac5010b8
...
...
@@ -27,12 +27,11 @@ class Votes:
log
.
exception
(
"
Adding new vote-info into
'
_votes_data
'
dict
"
)
raise
RuntimeError
(
"
Fatal error
"
)
key
=
voter
+
"
/
"
+
author
+
"
/
"
+
permlink
key
=
"
{}/{}/{}
"
.
format
(
voter
,
author
,
permlink
)
if
key
in
cls
.
_votes_data
:
cls
.
_votes_data
[
key
][
"
vote_percent
"
]
=
weight
cls
.
_votes_data
[
key
][
"
last_update
"
]
=
date
cls
.
_votes_data
[
key
][
"
block_num
"
]
=
block_num
else
:
cls
.
_votes_data
[
key
]
=
dict
(
voter
=
voter
,
author
=
author
,
...
...
@@ -45,20 +44,26 @@ class Votes:
block_num
=
block_num
)
@classmethod
def
effective_comment_vote_op
(
cls
,
key
,
vop
):
def
effective_comment_vote_op
(
cls
,
vop
):
"""
Process effective_comment_vote_operation
"""
if
cls
.
inside_flush
:
log
.
exception
(
"
Updating data in
'
_votes_data
'
using effective comment
"
)
raise
RuntimeError
(
"
Fatal error
"
)
assert
key
in
cls
.
_votes_data
cls
.
_votes_data
[
key
][
"
weight
"
]
=
vop
[
"
weight
"
]
cls
.
_votes_data
[
key
][
"
rshares
"
]
=
vop
[
"
rshares
"
]
cls
.
_votes_data
[
key
][
"
is_effective
"
]
=
True
cls
.
_votes_data
[
key
][
"
block_num
"
]
=
vop
[
'
block_num
'
]
key
=
"
{}/{}/{}
"
.
format
(
vop
[
'
voter
'
],
vop
[
'
author
'
],
vop
[
'
permlink
'
])
if
key
in
cls
.
_votes_data
:
cls
.
_votes_data
[
key
][
"
weight
"
]
=
vop
[
"
weight
"
]
cls
.
_votes_data
[
key
][
"
rshares
"
]
=
vop
[
"
rshares
"
]
cls
.
_votes_data
[
key
][
"
is_effective
"
]
=
True
cls
.
_votes_data
[
key
][
"
block_num
"
]
=
vop
[
'
block_num
'
]
else
:
cls
.
_votes_data
[
key
]
=
dict
(
voter
=
vop
[
'
voter
'
],
author
=
vop
[
'
author
'
],
permlink
=
vop
[
'
permlink
'
],
vote_percent
=
0
,
weight
=
vop
[
"
weight
"
],
rshares
=
vop
[
"
rshares
"
],
last_update
=
'
1970-01-01 00:00:00
'
,
is_effective
=
True
,
block_num
=
vop
[
'
block_num
'
])
@classmethod
def
flush
(
cls
):
"""
Flush vote data from cache to database
"""
...
...
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