mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +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 {
|
if d.blockchain.Config() != nil && d.blockchain.Config().XDPoS != nil {
|
||||||
epoch := d.blockchain.Config().XDPoS.Epoch
|
epoch := d.blockchain.Config().XDPoS.Epoch
|
||||||
gap := d.blockchain.Config().XDPoS.Gap
|
gap := d.blockchain.Config().XDPoS.Gap
|
||||||
length := len(results)
|
inserts := []*fetchResult{}
|
||||||
start := int(results[0].Header.Number.Uint64() % epoch)
|
for i := 0; i < len(results); i++ {
|
||||||
end := int(epoch - gap - uint64(start))
|
number := results[i].Header.Number.Uint64() % epoch
|
||||||
if end < 0 {
|
if number == 0 || number == epoch-1 || number == epoch-gap {
|
||||||
end = end + int(epoch)
|
inserts = append(inserts, results[i])
|
||||||
}
|
|
||||||
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 {
|
|
||||||
if d.chainInsertHook != nil {
|
if d.chainInsertHook != nil {
|
||||||
d.chainInsertHook(inserts)
|
d.chainInsertHook(inserts)
|
||||||
}
|
}
|
||||||
if err := d.importBlockResults(inserts); err != nil {
|
if err := d.importBlockResults(inserts); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
inserts = []*fetchResult{}
|
||||||
|
} else {
|
||||||
|
inserts = append(inserts, results[i])
|
||||||
}
|
}
|
||||||
start = end + 1
|
}
|
||||||
end = end + int(epoch)
|
if len(inserts) > 0 {
|
||||||
if start >= length {
|
if d.chainInsertHook != nil {
|
||||||
break
|
d.chainInsertHook(inserts)
|
||||||
|
}
|
||||||
|
if err := d.importBlockResults(inserts); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue