|
|
@ -9,9 +9,9 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/rlp" |
|
|
|
"github.com/ethereum/go-ethereum/rlp" |
|
|
|
"github.com/harmony-one/harmony/api/service/syncing" |
|
|
|
"github.com/harmony-one/harmony/api/service/legacysync" |
|
|
|
"github.com/harmony-one/harmony/api/service/syncing/downloader" |
|
|
|
"github.com/harmony-one/harmony/api/service/legacysync/downloader" |
|
|
|
downloader_pb "github.com/harmony-one/harmony/api/service/syncing/downloader/proto" |
|
|
|
downloader_pb "github.com/harmony-one/harmony/api/service/legacysync/downloader/proto" |
|
|
|
"github.com/harmony-one/harmony/core" |
|
|
|
"github.com/harmony-one/harmony/core" |
|
|
|
"github.com/harmony-one/harmony/core/types" |
|
|
|
"github.com/harmony-one/harmony/core/types" |
|
|
|
nodeconfig "github.com/harmony-one/harmony/internal/configs/node" |
|
|
|
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 { |
|
|
|
neighbor.Range(func(k, v interface{}) bool { |
|
|
|
p := v.(p2p.Peer) |
|
|
|
p := v.(p2p.Peer) |
|
|
|
t := p.Port |
|
|
|
t := p.Port |
|
|
|
p.Port = syncing.GetSyncingPort(t) |
|
|
|
p.Port = legacysync.GetSyncingPort(t) |
|
|
|
tmp = append(tmp, p) |
|
|
|
tmp = append(tmp, p) |
|
|
|
return true |
|
|
|
return true |
|
|
|
}) |
|
|
|
}) |
|
|
@ -69,8 +69,8 @@ func (node *Node) IsSameHeight() (uint64, bool) { |
|
|
|
return node.stateSync.IsSameBlockchainHeight(node.Blockchain()) |
|
|
|
return node.stateSync.IsSameBlockchainHeight(node.Blockchain()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (node *Node) getStateSync() *syncing.StateSync { |
|
|
|
func (node *Node) getStateSync() *legacysync.StateSync { |
|
|
|
return syncing.CreateStateSync(node.SelfPeer.IP, node.SelfPeer.Port, |
|
|
|
return legacysync.CreateStateSync(node.SelfPeer.IP, node.SelfPeer.Port, |
|
|
|
node.GetSyncID(), node.NodeConfig.Role() == nodeconfig.ExplorerNode) |
|
|
|
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
|
|
|
|
// 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) { |
|
|
|
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() |
|
|
|
shardID := bc.ShardID() |
|
|
|
peers, err := node.SyncingPeerProvider.SyncingPeers(shardID) |
|
|
|
peers, err := node.SyncingPeerProvider.SyncingPeers(shardID) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -321,7 +321,7 @@ func (node *Node) InitSyncingServer() { |
|
|
|
func (node *Node) StartSyncingServer() { |
|
|
|
func (node *Node) StartSyncingServer() { |
|
|
|
utils.Logger().Info().Msg("[SYNC] support_syncing: StartSyncingServer") |
|
|
|
utils.Logger().Info().Msg("[SYNC] support_syncing: StartSyncingServer") |
|
|
|
if node.downloaderServer.GrpcServer == nil { |
|
|
|
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 { |
|
|
|
if request.BlockHash == nil { |
|
|
|
return response, fmt.Errorf("[SYNC] GetBlockHashes Request BlockHash is 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) |
|
|
|
return response, fmt.Errorf("[SYNC] GetBlockHashes Request contains invalid Size %v", request.Size) |
|
|
|
} |
|
|
|
} |
|
|
|
size := uint64(request.Size) |
|
|
|
size := uint64(request.Size) |
|
|
@ -465,7 +465,7 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in |
|
|
|
return response, nil |
|
|
|
return response, nil |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
response.Type = downloader_pb.DownloaderResponse_FAIL |
|
|
|
response.Type = downloader_pb.DownloaderResponse_FAIL |
|
|
|
syncPort := syncing.GetSyncingPort(port) |
|
|
|
syncPort := legacysync.GetSyncingPort(port) |
|
|
|
client := downloader.ClientSetup(ip, syncPort) |
|
|
|
client := downloader.ClientSetup(ip, syncPort) |
|
|
|
if client == nil { |
|
|
|
if client == nil { |
|
|
|
utils.Logger().Warn(). |
|
|
|
utils.Logger().Warn(). |
|
|
|