From 75c2857761aa1cb2086578f386958f8c993b3470 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 26 Nov 2024 18:27:50 -0600 Subject: [PATCH] use different database file names for btc signet and testnet4 --- zetaclient/orchestrator/bootstrap.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/zetaclient/orchestrator/bootstrap.go b/zetaclient/orchestrator/bootstrap.go index e1d89df0fd..ce9632383d 100644 --- a/zetaclient/orchestrator/bootstrap.go +++ b/zetaclient/orchestrator/bootstrap.go @@ -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" @@ -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( @@ -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 @@ -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,