-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
polygon/bridge: fix bridge integration in stage mode #11646
Changes from all commits
4797124
80264ac
d36af91
ae11124
c9e614a
63fa8f5
f5bdefb
0a0f213
ebec670
86936a8
c2fde77
59045a7
d3e4aaf
d7a4812
9518b9d
c6c2645
c46673a
d4e6f4f
b1fa5cf
9ab2005
b0528bb
ab17de3
d83df94
5e0dc06
bc445b7
1d6e40e
fa63b74
056bbf5
6b2ae41
b83ba68
66f3b59
46d3961
6f1bedf
abe21b1
9d3c54b
d9ccb6f
e10703b
7346253
1626810
26db6be
3ed371d
d2534ab
828c038
768fc50
4ad2ef5
93ab2c5
ff39f8f
e7dac3c
ba04f4f
355d7d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ import ( | |
// doesn't change sequences of kv.EthTx | ||
// doesn't delete Receipts, Senders, Canonical markers, TotalDifficulty | ||
func PruneBorBlocks(tx kv.RwTx, blockTo uint64, blocksDeleteLimit int, SpanIdAt func(number uint64) uint64) (deleted int, err error) { | ||
// events | ||
c, err := tx.Cursor(kv.BorEventNums) | ||
if err != nil { | ||
return deleted, err | ||
|
@@ -70,14 +71,40 @@ func PruneBorBlocks(tx kv.RwTx, blockTo uint64, blocksDeleteLimit int, SpanIdAt | |
if err != nil { | ||
return deleted, err | ||
} | ||
|
||
epbCursor, err := tx.RwCursor(kv.BorEventProcessedBlocks) | ||
if err != nil { | ||
return deleted, err | ||
} | ||
|
||
defer epbCursor.Close() | ||
counter = blocksDeleteLimit | ||
for k, _, err = epbCursor.First(); err == nil && k != nil && counter > 0; k, _, err = epbCursor.Next() { | ||
blockNum := binary.BigEndian.Uint64(k) | ||
if blockNum >= blockTo { | ||
break | ||
} | ||
|
||
if err = epbCursor.DeleteCurrent(); err != nil { | ||
return deleted, err | ||
} | ||
|
||
deleted++ | ||
counter-- | ||
} | ||
if err != nil { | ||
return deleted, err | ||
} | ||
Comment on lines
+75
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be extracted into a sub-function. |
||
|
||
// spans | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be extracted to a |
||
firstSpanToKeep := SpanIdAt(blockTo) | ||
c2, err := tx.RwCursor(kv.BorSpans) | ||
if err != nil { | ||
return deleted, err | ||
} | ||
defer c2.Close() | ||
counter = blocksDeleteLimit | ||
for k, _, err := c2.First(); err == nil && k != nil && counter > 0; k, _, err = c2.Next() { | ||
for k, _, err = c2.First(); err == nil && k != nil && counter > 0; k, _, err = c2.Next() { | ||
spanId := binary.BigEndian.Uint64(k) | ||
if spanId >= firstSpanToKeep { | ||
break | ||
|
@@ -88,6 +115,9 @@ func PruneBorBlocks(tx kv.RwTx, blockTo uint64, blocksDeleteLimit int, SpanIdAt | |
deleted++ | ||
counter-- | ||
} | ||
if err != nil { | ||
return deleted, err | ||
} | ||
|
||
if snaptype.CheckpointsEnabled() { | ||
checkpointCursor, err := tx.RwCursor(kv.BorCheckpoints) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this isn't part or purpose of the PR, but since this function is a bit long, you could split it into smaller sub-functions each deleting from a certain table. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the return value also? Is
deleted
the total number of objects deleted?