diff --git a/internal/configs/sharding/localnet.go b/internal/configs/sharding/localnet.go index 41a870bdd..5985dfd2c 100644 --- a/internal/configs/sharding/localnet.go +++ b/internal/configs/sharding/localnet.go @@ -1,6 +1,7 @@ package shardingconfig import ( + "fmt" "math/big" "time" @@ -133,7 +134,16 @@ func (ls localnetSchedule) GetNetworkID() NetworkID { // GetShardingStructure is the sharding structure for localnet. func (ls localnetSchedule) GetShardingStructure(numShard, shardID int) []map[string]interface{} { - return genShardingStructure(numShard, shardID, LocalNetHTTPPattern, LocalNetWSPattern) + res := []map[string]interface{}{} + for i := 0; i < numShard; i++ { + res = append(res, map[string]interface{}{ + "current": int(shardID) == i, + "shardID": i, + "http": fmt.Sprintf("http://127.0.0.1:%d", 9500+i), + "ws": fmt.Sprintf("ws://127.0.0.1:%d", 9800+i), + }) + } + return res } var localnetReshardingEpoch = []*big.Int{big.NewInt(0), big.NewInt(localnetV1Epoch), big.NewInt(localnetV2Epoch)} diff --git a/internal/hmyapi/blockchain.go b/internal/hmyapi/blockchain.go index a99675c21..359672536 100644 --- a/internal/hmyapi/blockchain.go +++ b/internal/hmyapi/blockchain.go @@ -25,14 +25,6 @@ const ( defaultFromAddress = "0x0000000000000000000000000000000000000000" ) -// Constants for sharding structure. -const ( - MainNetHTTPPattern = "http://s%d.t.hmny.io:9500" - MainNetWSPattern = "ws://s%d.t.hmny.io:9800" - TestNetHTTPPattern = "http://s%d.b.hmny.io:9500" - TestNetWSPattern = "ws://s%d.s.hmny.io:9800" -) - // PublicBlockChainAPI provides an API to access the Harmony blockchain. // It offers only methods that operate on public data that is freely available to anyone. type PublicBlockChainAPI struct { @@ -71,20 +63,6 @@ func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, blockHash comm return nil, err } -// GenShardingStructure return sharding structure, given shard number and its patterns. -func GenShardingStructure(shardNum, shardID uint32, httpPattern, wsPattern string) []map[string]interface{} { - res := []map[string]interface{}{} - for i := 0; i < int(shardNum); i++ { - res = append(res, map[string]interface{}{ - "current": int(shardID) == i, - "shardID": i, - "http": fmt.Sprintf(httpPattern, i), - "ws": fmt.Sprintf(wsPattern, i), - }) - } - return res -} - // GetShardingStructure returns an array of sharding structures. func (s *PublicBlockChainAPI) GetShardingStructure(ctx context.Context) ([]map[string]interface{}, error) { // Get header and number of shards.