axieinfinity / ronin

A DPoS blockchain.
GNU Lesser General Public License v3.0
67 stars 30 forks source link

Change ancient chain segments from root ancient to sub folders #572

Closed huyngopt1994 closed 1 month ago

huyngopt1994 commented 1 month ago

Reference https://github.com/ethereum/go-ethereum/pull/25487 .

Before The chain segment should be stored in <chaindata/ancient>. Now it will locate in <chaindata/ancient/chain> in case u start the new disk, otherwise support backward compatibility

Handling main idea is here.

    if !common.FileExist(freezer) {
        if !common.FileExist(ancient) {
            // The entire ancient store is not initialized, still use the sub
            // folder for initialization.
        } else {
            // Ancient root is already initialized, then we hold the assumption
            // that chain freezer is also initialized and located in root folder.
            // In this case fallback to legacy location.
            freezer = ancient
            log.Info("Found legacy ancient chain path", "location", ancient)
        }
    }