|
|
@ -25,14 +25,6 @@ const ( |
|
|
|
defaultFromAddress = "0x0000000000000000000000000000000000000000" |
|
|
|
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.
|
|
|
|
// PublicBlockChainAPI provides an API to access the Harmony blockchain.
|
|
|
|
// It offers only methods that operate on public data that is freely available to anyone.
|
|
|
|
// It offers only methods that operate on public data that is freely available to anyone.
|
|
|
|
type PublicBlockChainAPI struct { |
|
|
|
type PublicBlockChainAPI struct { |
|
|
@ -71,20 +63,6 @@ func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, blockHash comm |
|
|
|
return nil, err |
|
|
|
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.
|
|
|
|
// GetShardingStructure returns an array of sharding structures.
|
|
|
|
func (s *PublicBlockChainAPI) GetShardingStructure(ctx context.Context) ([]map[string]interface{}, error) { |
|
|
|
func (s *PublicBlockChainAPI) GetShardingStructure(ctx context.Context) ([]map[string]interface{}, error) { |
|
|
|
// Get header and number of shards.
|
|
|
|
// Get header and number of shards.
|
|
|
|