diff --git a/api/service/explorer/service.go b/api/service/explorer/service.go index 2f554d639..b5ea617a9 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 d0ad750a3..4b331d428 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 d02d2d836..e4b62a5ef 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 ea82c19b9..adae24738 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 ae8c7dae9..b829cc1d2 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 3f7a28ddd..7c1892c7b 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 895133ec1..9d566313f 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 e916b9a00..c6905d351 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 09f3e98ab..bb479ebf4 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 8acee81d6..75ace9333 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().