mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 13:44:31 +00:00
fix tiny error when full node import block
This commit is contained in:
parent
5ebc19f70a
commit
579adf1c8e
1 changed files with 15 additions and 19 deletions
|
|
@ -1326,32 +1326,28 @@ func (d *Downloader) processFullSyncContent() error {
|
|||
if d.blockchain.Config() != nil && d.blockchain.Config().XDPoS != nil {
|
||||
epoch := d.blockchain.Config().XDPoS.Epoch
|
||||
gap := d.blockchain.Config().XDPoS.Gap
|
||||
length := len(results)
|
||||
start := int(results[0].Header.Number.Uint64() % epoch)
|
||||
end := int(epoch - gap - uint64(start))
|
||||
if end < 0 {
|
||||
end = end + int(epoch)
|
||||
}
|
||||
start = 0
|
||||
for {
|
||||
if end >= length {
|
||||
end = length - 1
|
||||
}
|
||||
inserts := make([]*fetchResult, end-start+1)
|
||||
copy(inserts, results[start:end+1])
|
||||
if len(inserts) > 0 {
|
||||
inserts := []*fetchResult{}
|
||||
for i := 0; i < len(results); i++ {
|
||||
number := results[i].Header.Number.Uint64() % epoch
|
||||
if number == 0 || number == epoch-1 || number == epoch-gap {
|
||||
inserts = append(inserts, results[i])
|
||||
if d.chainInsertHook != nil {
|
||||
d.chainInsertHook(inserts)
|
||||
}
|
||||
if err := d.importBlockResults(inserts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
inserts = []*fetchResult{}
|
||||
} else {
|
||||
inserts = append(inserts, results[i])
|
||||
}
|
||||
start = end + 1
|
||||
end = end + int(epoch)
|
||||
if start >= length {
|
||||
break
|
||||
}
|
||||
if len(inserts) > 0 {
|
||||
if d.chainInsertHook != nil {
|
||||
d.chainInsertHook(inserts)
|
||||
}
|
||||
if err := d.importBlockResults(inserts); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue