From c05e150aa7e2b120421836e5168e10c42bc72b1d Mon Sep 17 00:00:00 2001 From: Jacky Wang Date: Fri, 12 Mar 2021 18:34:16 -0800 Subject: [PATCH] [stream] rename dns syncing package to legacysync --- api/service/explorer/service.go | 6 +++--- .../downloader/client.go | 2 +- .../downloader/errors.go | 0 .../{syncing => legacysync}/downloader/gen.sh | 0 .../downloader/interface.go | 2 +- .../downloader/proto/downloader.go | 0 .../downloader/proto/downloader.pb.go | 0 .../downloader/proto/downloader.proto | 0 .../downloader/server.go | 2 +- api/service/{syncing => legacysync}/errors.go | 2 +- .../{syncing => legacysync}/syncing.go | 6 +++--- .../{syncing => legacysync}/syncing.md | 0 .../{syncing => legacysync}/syncing_test.go | 4 ++-- cmd/harmony/main.go | 4 ++-- node/node.go | 6 +++--- node/node_syncing.go | 20 +++++++++---------- 16 files changed, 27 insertions(+), 27 deletions(-) rename api/service/{syncing => legacysync}/downloader/client.go (98%) rename api/service/{syncing => legacysync}/downloader/errors.go (100%) rename api/service/{syncing => legacysync}/downloader/gen.sh (100%) rename api/service/{syncing => legacysync}/downloader/interface.go (83%) rename api/service/{syncing => legacysync}/downloader/proto/downloader.go (100%) rename api/service/{syncing => legacysync}/downloader/proto/downloader.pb.go (100%) rename api/service/{syncing => legacysync}/downloader/proto/downloader.proto (100%) rename api/service/{syncing => legacysync}/downloader/server.go (95%) rename api/service/{syncing => legacysync}/errors.go (97%) rename api/service/{syncing => legacysync}/syncing.go (99%) rename api/service/{syncing => legacysync}/syncing.md (100%) rename api/service/{syncing => legacysync}/syncing_test.go (98%) diff --git a/api/service/explorer/service.go b/api/service/explorer/service.go index 2f554d6394..b5ea617a96 100644 --- a/api/service/explorer/service.go +++ b/api/service/explorer/service.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/gorilla/mux" msg_pb "github.com/harmony-one/harmony/api/proto/message" - "github.com/harmony-one/harmony/api/service/syncing" + "github.com/harmony-one/harmony/api/service/legacysync" "github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/internal/chain" "github.com/harmony-one/harmony/internal/common" @@ -45,12 +45,12 @@ type Service struct { Storage *Storage server *http.Server messageChan chan *msg_pb.Message - stateSync *syncing.StateSync + stateSync *legacysync.StateSync blockchain *core.BlockChain } // New returns explorer service. -func New(selfPeer *p2p.Peer, ss *syncing.StateSync, bc *core.BlockChain) *Service { +func New(selfPeer *p2p.Peer, ss *legacysync.StateSync, bc *core.BlockChain) *Service { return &Service{IP: selfPeer.IP, Port: selfPeer.Port, stateSync: ss, blockchain: bc} } diff --git a/api/service/syncing/downloader/client.go b/api/service/legacysync/downloader/client.go similarity index 98% rename from api/service/syncing/downloader/client.go rename to api/service/legacysync/downloader/client.go index d0ad750a30..4b331d4283 100644 --- a/api/service/syncing/downloader/client.go +++ b/api/service/legacysync/downloader/client.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - pb "github.com/harmony-one/harmony/api/service/syncing/downloader/proto" + pb "github.com/harmony-one/harmony/api/service/legacysync/downloader/proto" "github.com/harmony-one/harmony/internal/utils" "google.golang.org/grpc" ) diff --git a/api/service/syncing/downloader/errors.go b/api/service/legacysync/downloader/errors.go similarity index 100% rename from api/service/syncing/downloader/errors.go rename to api/service/legacysync/downloader/errors.go diff --git a/api/service/syncing/downloader/gen.sh b/api/service/legacysync/downloader/gen.sh similarity index 100% rename from api/service/syncing/downloader/gen.sh rename to api/service/legacysync/downloader/gen.sh diff --git a/api/service/syncing/downloader/interface.go b/api/service/legacysync/downloader/interface.go similarity index 83% rename from api/service/syncing/downloader/interface.go rename to api/service/legacysync/downloader/interface.go index d02d2d8366..e4b62a5efe 100644 --- a/api/service/syncing/downloader/interface.go +++ b/api/service/legacysync/downloader/interface.go @@ -1,7 +1,7 @@ package downloader import ( - pb "github.com/harmony-one/harmony/api/service/syncing/downloader/proto" + pb "github.com/harmony-one/harmony/api/service/legacysync/downloader/proto" ) // DownloadInterface is the interface for downloader package. diff --git a/api/service/syncing/downloader/proto/downloader.go b/api/service/legacysync/downloader/proto/downloader.go similarity index 100% rename from api/service/syncing/downloader/proto/downloader.go rename to api/service/legacysync/downloader/proto/downloader.go diff --git a/api/service/syncing/downloader/proto/downloader.pb.go b/api/service/legacysync/downloader/proto/downloader.pb.go similarity index 100% rename from api/service/syncing/downloader/proto/downloader.pb.go rename to api/service/legacysync/downloader/proto/downloader.pb.go diff --git a/api/service/syncing/downloader/proto/downloader.proto b/api/service/legacysync/downloader/proto/downloader.proto similarity index 100% rename from api/service/syncing/downloader/proto/downloader.proto rename to api/service/legacysync/downloader/proto/downloader.proto diff --git a/api/service/syncing/downloader/server.go b/api/service/legacysync/downloader/server.go similarity index 95% rename from api/service/syncing/downloader/server.go rename to api/service/legacysync/downloader/server.go index ea82c19b96..adae247380 100644 --- a/api/service/syncing/downloader/server.go +++ b/api/service/legacysync/downloader/server.go @@ -5,7 +5,7 @@ import ( "log" "net" - pb "github.com/harmony-one/harmony/api/service/syncing/downloader/proto" + pb "github.com/harmony-one/harmony/api/service/legacysync/downloader/proto" "github.com/harmony-one/harmony/internal/utils" "google.golang.org/grpc" diff --git a/api/service/syncing/errors.go b/api/service/legacysync/errors.go similarity index 97% rename from api/service/syncing/errors.go rename to api/service/legacysync/errors.go index ae8c7dae91..b829cc1d28 100644 --- a/api/service/syncing/errors.go +++ b/api/service/legacysync/errors.go @@ -1,4 +1,4 @@ -package syncing +package legacysync import "errors" diff --git a/api/service/syncing/syncing.go b/api/service/legacysync/syncing.go similarity index 99% rename from api/service/syncing/syncing.go rename to api/service/legacysync/syncing.go index 3f7a28dddd..7c1892c7b9 100644 --- a/api/service/syncing/syncing.go +++ b/api/service/legacysync/syncing.go @@ -1,4 +1,4 @@ -package syncing +package legacysync import ( "bytes" @@ -14,8 +14,8 @@ import ( "github.com/Workiva/go-datastructures/queue" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" - "github.com/harmony-one/harmony/api/service/syncing/downloader" - pb "github.com/harmony-one/harmony/api/service/syncing/downloader/proto" + "github.com/harmony-one/harmony/api/service/legacysync/downloader" + pb "github.com/harmony-one/harmony/api/service/legacysync/downloader/proto" "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/consensus/engine" "github.com/harmony-one/harmony/core" diff --git a/api/service/syncing/syncing.md b/api/service/legacysync/syncing.md similarity index 100% rename from api/service/syncing/syncing.md rename to api/service/legacysync/syncing.md diff --git a/api/service/syncing/syncing_test.go b/api/service/legacysync/syncing_test.go similarity index 98% rename from api/service/syncing/syncing_test.go rename to api/service/legacysync/syncing_test.go index 895133ec1b..9d566313f2 100644 --- a/api/service/syncing/syncing_test.go +++ b/api/service/legacysync/syncing_test.go @@ -1,4 +1,4 @@ -package syncing +package legacysync import ( "errors" @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/harmony-one/harmony/api/service/syncing/downloader" + "github.com/harmony-one/harmony/api/service/legacysync/downloader" "github.com/harmony-one/harmony/p2p" "github.com/stretchr/testify/assert" ) diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index e916b9a009..c6905d351f 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -20,8 +20,8 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/api/service" + "github.com/harmony-one/harmony/api/service/legacysync" "github.com/harmony-one/harmony/api/service/prometheus" - "github.com/harmony-one/harmony/api/service/syncing" "github.com/harmony-one/harmony/common/fdlimit" "github.com/harmony-one/harmony/common/ntp" "github.com/harmony-one/harmony/consensus" @@ -633,7 +633,7 @@ func setupConsensusAndNode(hc harmonyConfig, nodeConfig *nodeconfig.ConfigType) } else if hc.Network.LegacySyncing { currentNode.SyncingPeerProvider = node.NewLegacySyncingPeerProvider(currentNode) } else { - currentNode.SyncingPeerProvider = node.NewDNSSyncingPeerProvider(hc.Network.DNSZone, syncing.GetSyncingPort(strconv.Itoa(hc.Network.DNSPort))) + currentNode.SyncingPeerProvider = node.NewDNSSyncingPeerProvider(hc.Network.DNSZone, legacysync.GetSyncingPort(strconv.Itoa(hc.Network.DNSPort))) } // TODO: refactor the creation of blockchain out of node.New() diff --git a/node/node.go b/node/node.go index 09f3e98ab8..bb479ebf41 100644 --- a/node/node.go +++ b/node/node.go @@ -17,8 +17,8 @@ import ( msg_pb "github.com/harmony-one/harmony/api/proto/message" proto_node "github.com/harmony-one/harmony/api/proto/node" "github.com/harmony-one/harmony/api/service" - "github.com/harmony-one/harmony/api/service/syncing" - "github.com/harmony-one/harmony/api/service/syncing/downloader" + "github.com/harmony-one/harmony/api/service/legacysync" + "github.com/harmony-one/harmony/api/service/legacysync/downloader" "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core/rawdb" @@ -90,7 +90,7 @@ type Node struct { downloaderServer *downloader.Server // Syncing component. syncID [SyncIDLength]byte // a unique ID for the node during the state syncing process with peers - stateSync, beaconSync *syncing.StateSync + stateSync, beaconSync *legacysync.StateSync peerRegistrationRecord map[string]*syncConfig // record registration time (unixtime) of peers begin in syncing SyncingPeerProvider SyncingPeerProvider // The p2p host used to send/receive p2p messages diff --git a/node/node_syncing.go b/node/node_syncing.go index 8acee81d6b..75ace93339 100644 --- a/node/node_syncing.go +++ b/node/node_syncing.go @@ -9,9 +9,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" - "github.com/harmony-one/harmony/api/service/syncing" - "github.com/harmony-one/harmony/api/service/syncing/downloader" - downloader_pb "github.com/harmony-one/harmony/api/service/syncing/downloader/proto" + "github.com/harmony-one/harmony/api/service/legacysync" + "github.com/harmony-one/harmony/api/service/legacysync/downloader" + downloader_pb "github.com/harmony-one/harmony/api/service/legacysync/downloader/proto" "github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core/types" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" @@ -49,7 +49,7 @@ func getNeighborPeers(neighbor *sync.Map) []p2p.Peer { neighbor.Range(func(k, v interface{}) bool { p := v.(p2p.Peer) t := p.Port - p.Port = syncing.GetSyncingPort(t) + p.Port = legacysync.GetSyncingPort(t) tmp = append(tmp, p) return true }) @@ -69,8 +69,8 @@ func (node *Node) IsSameHeight() (uint64, bool) { return node.stateSync.IsSameBlockchainHeight(node.Blockchain()) } -func (node *Node) getStateSync() *syncing.StateSync { - return syncing.CreateStateSync(node.SelfPeer.IP, node.SelfPeer.Port, +func (node *Node) getStateSync() *legacysync.StateSync { + return legacysync.CreateStateSync(node.SelfPeer.IP, node.SelfPeer.Port, node.GetSyncID(), node.NodeConfig.Role() == nodeconfig.ExplorerNode) } @@ -245,7 +245,7 @@ func (node *Node) DoSyncing(bc *core.BlockChain, worker *worker.Worker, willJoin // doSync keep the node in sync with other peers, willJoinConsensus means the node will try to join consensus after catch up func (node *Node) doSync(bc *core.BlockChain, worker *worker.Worker, willJoinConsensus bool) { - if node.stateSync.GetActivePeerNumber() < syncing.NumPeersLowBound { + if node.stateSync.GetActivePeerNumber() < legacysync.NumPeersLowBound { shardID := bc.ShardID() peers, err := node.SyncingPeerProvider.SyncingPeers(shardID) if err != nil { @@ -321,7 +321,7 @@ func (node *Node) InitSyncingServer() { func (node *Node) StartSyncingServer() { utils.Logger().Info().Msg("[SYNC] support_syncing: StartSyncingServer") if node.downloaderServer.GrpcServer == nil { - node.downloaderServer.Start(node.SelfPeer.IP, syncing.GetSyncingPort(node.SelfPeer.Port)) + node.downloaderServer.Start(node.SelfPeer.IP, legacysync.GetSyncingPort(node.SelfPeer.Port)) } } @@ -371,7 +371,7 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in if request.BlockHash == nil { return response, fmt.Errorf("[SYNC] GetBlockHashes Request BlockHash is NIL") } - if request.Size == 0 || request.Size > syncing.SyncLoopBatchSize { + if request.Size == 0 || request.Size > legacysync.SyncLoopBatchSize { return response, fmt.Errorf("[SYNC] GetBlockHashes Request contains invalid Size %v", request.Size) } size := uint64(request.Size) @@ -465,7 +465,7 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in return response, nil } else { response.Type = downloader_pb.DownloaderResponse_FAIL - syncPort := syncing.GetSyncingPort(port) + syncPort := legacysync.GetSyncingPort(port) client := downloader.ClientSetup(ip, syncPort) if client == nil { utils.Logger().Warn().