Skip to content

Commit

Permalink
use different database file names for btc signet and testnet4
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Nov 27, 2024
1 parent cc3bc86 commit 75c2857
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions zetaclient/orchestrator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/pkg/errors"
"github.com/tonkeeper/tongo/ton"

"github.com/zeta-chain/node/pkg/chains"
toncontracts "github.com/zeta-chain/node/pkg/contracts/ton"
"github.com/zeta-chain/node/zetaclient/chains/base"
btcobserver "github.com/zeta-chain/node/zetaclient/chains/bitcoin/observer"
Expand All @@ -32,10 +33,6 @@ import (
"github.com/zeta-chain/node/zetaclient/metrics"
)

// btcDatabaseFilename is the Bitcoin database file name now used in mainnet,
// so we keep using it here for backward compatibility
const btcDatabaseFilename = "btc_chain_client"

// CreateSignerMap creates a map of interfaces.ChainSigner (by chainID) for all chains in the config.
// Note that signer construction failure for a chain does not prevent the creation of signers for other chains.
func CreateSignerMap(
Expand Down Expand Up @@ -363,7 +360,7 @@ func syncObserverMap(
continue
}

database, err := db.NewFromSqlite(dbpath, btcDatabaseFilename, true)
database, err := db.NewFromSqlite(dbpath, btcDatabaseFileName(*rawChain), true)
if err != nil {
logger.Std.Error().Err(err).Msgf("unable to open database for BTC chain %d", chainID)
continue
Expand Down Expand Up @@ -481,6 +478,20 @@ func syncObserverMap(
return added, removed, nil
}

func btcDatabaseFileName(chain chains.Chain) string {
// btcDatabaseFilename is the Bitcoin database file name now used in mainnet and testnet3
// so we keep using it here for backward compatibility
const btcDatabaseFilename = "btc_chain_client"

// For additional bitcoin networks, we use the chain name as the database file name
switch chain.ChainId {
case chains.BitcoinMainnet.ChainId, chains.BitcoinTestnet.ChainId:
return btcDatabaseFilename
default:
return chain.Name
}
}

func makeTONClient(
ctx context.Context,
cfg config.TONConfig,
Expand Down

0 comments on commit 75c2857

Please sign in to comment.