add current to the sharding structure for sdk

pull/1429/head
Minh Doan 5 years ago
parent cc6423db58
commit 9aab6dc5d0
  1. 5
      hmy/api_backend.go
  2. 4
      hmy/backend.go
  3. 6
      internal/hmyapi/blockchain.go
  4. 2
      node/rpc.go

@ -228,3 +228,8 @@ func (b *APIBackend) GetEVM(ctx context.Context, msg core.Message, state *state.
func (b *APIBackend) RPCGasCap() *big.Int {
return b.hmy.RPCGasCap // TODO(ricl): should be hmy.config.RPCGasCap
}
// GetShardID returns the gas cap of rpc
func (b *APIBackend) GetShardID() uint32 {
return b.hmy.shardID
}

@ -37,6 +37,7 @@ type Harmony struct {
// TODO(ricl): this is never set. Will result in nil pointer bug
// RPCGasCap is the global gas cap for eth-call variants.
RPCGasCap *big.Int `toml:",omitempty"`
shardID uint32
}
// NodeAPI is the list of functions from node used to call rpc apis.
@ -50,7 +51,7 @@ type NodeAPI interface {
// New creates a new Harmony object (including the
// initialisation of the common Harmony object)
func New(nodeAPI NodeAPI, txPool *core.TxPool, eventMux *event.TypeMux) (*Harmony, error) {
func New(nodeAPI NodeAPI, txPool *core.TxPool, eventMux *event.TypeMux, shardID uint32) (*Harmony, error) {
chainDb := nodeAPI.Blockchain().ChainDB()
hmy := &Harmony{
shutdownChan: make(chan bool),
@ -63,6 +64,7 @@ func New(nodeAPI NodeAPI, txPool *core.TxPool, eventMux *event.TypeMux) (*Harmon
bloomIndexer: NewBloomIndexer(chainDb, params.BloomBitsBlocks, params.BloomConfirms),
nodeAPI: nodeAPI,
networkID: 1, // TODO(ricl): this should be from config
shardID: shardID,
}
hmy.APIBackend = &APIBackend{hmy}

@ -69,14 +69,16 @@ func (s *PublicBlockChainAPI) GetShardingStructure(ctx context.Context) ([]map[s
if core.ShardingSchedule.GetNetworkID() == shardingconfig.MainNet {
return []map[string]interface{}{
map[string]interface{}{
"current": s.b.GetShardID() == 0,
"shardID": "0",
"http": "http://s0.t.hmy.io:9500",
"ws": "ws://s0.t.hmy.io:9800",
},
map[string]interface{}{
"current": s.b.GetShardID() == 1,
"shardID": "1",
"http": "http://s1.t.hmy.io:9500",
"ws": "ws://s1.t.hmy.io",
"ws": "ws://s1.t.hmy.io:9800",
},
map[string]interface{}{
"shardID": "2",
@ -99,7 +101,7 @@ func (s *PublicBlockChainAPI) GetShardingStructure(ctx context.Context) ([]map[s
map[string]interface{}{
"shardID": "1",
"http": "http://s1.b.hmy.io:9500",
"ws": "ws://s1.s.hmy.io",
"ws": "ws://s1.s.hmy.io:9800",
},
}, nil
} else {

@ -46,7 +46,7 @@ var (
// StartRPC start RPC service
func (node *Node) StartRPC(nodePort string) error {
// Gather all the possible APIs to surface
harmony, _ = hmy.New(node, node.TxPool, new(event.TypeMux))
harmony, _ = hmy.New(node, node.TxPool, new(event.TypeMux), node.Consensus.ShardID)
apis := node.APIs()

Loading…
Cancel
Save