mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
allow rewinding to block 0
This commit is contained in:
parent
cc22e0cdf0
commit
7b10aa443b
4 changed files with 10 additions and 1 deletions
|
|
@ -354,7 +354,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
|
|||
return newcfg, stored, errors.New("missing head header")
|
||||
}
|
||||
compatErr := storedcfg.CheckCompatible(newcfg, head.Number.Uint64(), head.Time)
|
||||
if compatErr != nil && ((head.Number.Uint64() != 0 && compatErr.RewindToBlock != 0) || (head.Time != 0 && compatErr.RewindToTime != 0)) {
|
||||
if compatErr != nil && ((head.Number.Uint64() != 0 && compatErr.RewindByBlock) || (head.Time != 0 && compatErr.RewindToTime != 0)) {
|
||||
return newcfg, stored, compatErr
|
||||
}
|
||||
// Don't overwrite if the old is identical to the new
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ func testSetupGenesis(t *testing.T, scheme string) {
|
|||
What: "Homestead fork block",
|
||||
StoredBlock: big.NewInt(2),
|
||||
NewBlock: big.NewInt(3),
|
||||
RewindByBlock: true,
|
||||
RewindToBlock: 1,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -843,6 +843,9 @@ type ConfigCompatError struct {
|
|||
// the block number to which the local chain must be rewound to correct the error
|
||||
RewindToBlock uint64
|
||||
|
||||
// the flag to tell whether it's rewinding by block or time
|
||||
RewindByBlock bool
|
||||
|
||||
// the timestamp to which the local chain must be rewound to correct the error
|
||||
RewindToTime uint64
|
||||
}
|
||||
|
|
@ -862,6 +865,7 @@ func newBlockCompatError(what string, storedblock, newblock *big.Int) *ConfigCom
|
|||
StoredBlock: storedblock,
|
||||
NewBlock: newblock,
|
||||
RewindToBlock: 0,
|
||||
RewindByBlock: true,
|
||||
}
|
||||
if rew != nil && rew.Sign() > 0 {
|
||||
err.RewindToBlock = rew.Uint64() - 1
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ func TestCheckCompatible(t *testing.T) {
|
|||
StoredBlock: big.NewInt(0),
|
||||
NewBlock: nil,
|
||||
RewindToBlock: 0,
|
||||
RewindByBlock: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -63,6 +64,7 @@ func TestCheckCompatible(t *testing.T) {
|
|||
StoredBlock: big.NewInt(0),
|
||||
NewBlock: big.NewInt(1),
|
||||
RewindToBlock: 0,
|
||||
RewindByBlock: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -74,6 +76,7 @@ func TestCheckCompatible(t *testing.T) {
|
|||
StoredBlock: big.NewInt(10),
|
||||
NewBlock: big.NewInt(20),
|
||||
RewindToBlock: 9,
|
||||
RewindByBlock: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -91,6 +94,7 @@ func TestCheckCompatible(t *testing.T) {
|
|||
StoredBlock: nil,
|
||||
NewBlock: big.NewInt(31),
|
||||
RewindToBlock: 30,
|
||||
RewindByBlock: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue