OpenAtomFoundation / xupercore

The kernel of xuperchain.
Apache License 2.0
61 stars 47 forks source link

ledger: copy on write block cache #263

Closed icexin closed 2 years ago

icexin commented 2 years ago

Description

代码中存在着从block cache中获取block之后修改NextHash字段的行为,另外一个并发的先获取block再marshal的协程就会触发竞争,导致panic。

这个PR在每个写block的地方都拷贝了一份。

update #251

codecov-commenter commented 2 years ago

Codecov Report

Merging #263 (8cb7f15) into master (37b7714) will decrease coverage by 0.00%. The diff coverage is 58.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #263      +/-   ##
==========================================
- Coverage   46.66%   46.66%   -0.01%     
==========================================
  Files         136      136              
  Lines       12068    12073       +5     
==========================================
+ Hits         5632     5634       +2     
- Misses       5276     5278       +2     
- Partials     1160     1161       +1     
Impacted Files Coverage Δ
bcs/ledger/xledger/ledger/branch_manage.go 17.07% <0.00%> (ø)
bcs/ledger/xledger/ledger/ledger.go 56.63% <77.77%> (+0.02%) :arrow_up:
bcs/consensus/xpoa/xpoa.go 53.76% <0.00%> (-2.16%) :arrow_down:
bcs/ledger/xledger/state/state.go 47.61% <0.00%> (+0.37%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 37b7714...8cb7f15. Read the comment docs.