diff --git a/api/service/explorer/service.go b/api/service/explorer/service.go index 62f3fc7f45..85755a9f5c 100644 --- a/api/service/explorer/service.go +++ b/api/service/explorer/service.go @@ -57,7 +57,12 @@ type Service struct { // New returns explorer service. func New(harmonyConfig *harmonyconfig.HarmonyConfig, selfPeer *p2p.Peer, bc *core.BlockChain, backend hmy.NodeAPI) *Service { - dbPath := defaultDBPath(selfPeer.IP, selfPeer.Port) + pathIP := selfPeer.IP + if harmonyConfig.General.UseTiKV { + pathIP = nodeconfig.DefaultPublicListenIP // using the same pathIP for the TIKV mode, so it remains constant across readers and writers, since this is used as prefix for the DB keys + } + + dbPath := defaultDBPath(pathIP, selfPeer.Port) storage, err := newStorage(harmonyConfig, bc, dbPath) if err != nil { utils.Logger().Fatal().Err(err).Msg("cannot open explorer DB") diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index d13c360d66..596fb37a0b 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -434,6 +434,8 @@ func setupNodeAndRun(hc harmonyconfig.HarmonyConfig) { currentNode.StartGRPCSyncClient() } + currentNode.NodeSyncing() + if err := currentNode.StartServices(); err != nil { fmt.Fprint(os.Stderr, err.Error()) os.Exit(-1) diff --git a/node/node_syncing.go b/node/node_syncing.go index 3b4b5ac557..3d043e0a8c 100644 --- a/node/node_syncing.go +++ b/node/node_syncing.go @@ -342,17 +342,21 @@ func (node *Node) StartGRPCSyncClient() { Msg("SupportBeaconSyncing") go node.doBeaconSyncing() } +} +// NodeSyncing makes sure to start all the processes needed to sync the node based on different configuration factors. +func (node *Node) NodeSyncing() { if node.HarmonyConfig.General.UseTiKV { - node.syncFromTiKVWriter() + node.syncFromTiKVWriter() // this is for both reader and backup writers - if node.HarmonyConfig.TiKV.Role == "Writer" { - node.supportSyncing() - } else { + if node.HarmonyConfig.TiKV.Role == "Reader" { node.Consensus.UpdateConsensusInformation() } - } else { - node.supportSyncing() + if node.HarmonyConfig.TiKV.Role == "Writer" { + node.supportSyncing() // the writer needs to be in sync with it's other peers + } + } else if !node.HarmonyConfig.General.IsOffline && node.HarmonyConfig.DNSSync.Client { + node.supportSyncing() // for non-writer-reader mode a.k.a tikv nodes } }