File tree Expand file tree Collapse file tree 1 file changed +4
-11
lines changed Expand file tree Collapse file tree 1 file changed +4
-11
lines changed Original file line number Diff line number Diff line change @@ -124,19 +124,12 @@ func (cv *ChainView) RawReceipts(number uint64) types.Receipts {
124
124
125
125
// SharedRange returns the block range shared by two chain views.
126
126
func (cv * ChainView ) SharedRange (cv2 * ChainView ) common.Range [uint64 ] {
127
- cv .lock .Lock ()
128
- defer cv .lock .Unlock ()
129
-
130
- if cv == nil || cv2 == nil || ! cv .extendNonCanonical () || ! cv2 .extendNonCanonical () {
127
+ if cv == nil || cv2 == nil {
131
128
return common.Range [uint64 ]{}
132
129
}
133
- var sharedLen uint64
134
- for n := min (cv .headNumber + 1 - uint64 (len (cv .hashes )), cv2 .headNumber + 1 - uint64 (len (cv2 .hashes ))); n <= cv .headNumber && n <= cv2 .headNumber ; n ++ {
135
- h1 , h2 := cv .blockHash (n ), cv2 .blockHash (n )
136
- if h1 != h2 || h1 == (common.Hash {}) {
137
- break
138
- }
139
- sharedLen = n + 1
130
+ sharedLen := min (cv .headNumber , cv2 .headNumber ) + 1
131
+ for sharedLen > 0 && cv .BlockId (sharedLen - 1 ) != cv2 .BlockId (sharedLen - 1 ) {
132
+ sharedLen --
140
133
}
141
134
return common .NewRange (0 , sharedLen )
142
135
}
You can’t perform that action at this time.
0 commit comments