• Tyler Smith's avatar
    feat,interop: add db syncing between nodes (#13357) · 590fc814
    Tyler Smith authored
    * feature: Allow adding arbitrary HTTP handlers to RPC HTTP Server.
    
    * feature: Add sync package to handle streaming db files between nodes.
    
    * tweak: Add DB sync server handler to op-supervisor server.
    
    * feature: Use db sync if it's configured and there's no existing db.
    
    * tweak: Use retry lib, which also adds max retries.
    
    * rename: SyncRPC -> SyncEndpoint.
    
    * tweak: Make the initial chain set part of the Server constructor.
    
    * cleanup: Remove unused functions.
    
    * rename: client -> syncClient to avoid package collision.
    
    * fix: Load DepSet and use for sync server.
    
    * tweak: Use client.BasicHTTPClient for sync client.
    
    * fix: Don't double concat the path.
    
    * tests,fix: Set sync resume to true.
    
    * tweak: Add error context.
    
    * tweak: Make http body close lint-friendly.
    
    * tweak: Change retry policy to backoff from 1s to 30s, up to 10 minutes.
    
    * tests,fix: Use require.ErrorIs to handle wrapped error.
    590fc814
sync.go 573 Bytes
package sync

import (
	"github.com/ethereum/go-ethereum/log"
)

const (
	DBLocalSafe Database = "local_safe"
	DBCrossSafe Database = "cross_safe"
)

// Databases maps a database alias to its actual name on disk
var Databases = map[Database]string{
	DBLocalSafe: "local_safe.db",
	DBCrossSafe: "cross_safe.db",
}

type Database string

func (d Database) String() string {
	return string(d)
}

func (d Database) File() string {
	return Databases[d]
}

// Config contains all configuration for the Server or Client.
type Config struct {
	DataDir string
	Logger  log.Logger
}