Skip to content

Commit 4c5cd68

Browse files
author
sunhongtao
committed
feat: add other method in easynode space
1 parent 3d38bb6 commit 4c5cd68

File tree

16 files changed

+904
-475
lines changed

16 files changed

+904
-475
lines changed

blockchain/config/configutil.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func LoadConfig(path string) Config {
2727
}
2828

2929
list := gjson.ParseBytes(b).Get("Nodes").Array()
30+
cfg.Cluster = make(map[int64][]*NodeCluster)
3031
for _, v := range list {
3132
chainCode := v.Get("BlockChain").Int()
3233
var node NodeCluster
@@ -39,10 +40,8 @@ func LoadConfig(path string) Config {
3940
m = append(m, &node)
4041
cfg.Cluster[chainCode] = m
4142
} else {
42-
m := make(map[int64][]*NodeCluster, 1)
4343
nodeList := []*NodeCluster{&node}
44-
m[chainCode] = nodeList
45-
cfg.Cluster = m
44+
cfg.Cluster[chainCode] = nodeList
4645
}
4746
}
4847

blockchain/service/bnb/bnb.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/0xcregis/easynode/blockchain"
1212
"github.com/0xcregis/easynode/blockchain/chain"
1313
"github.com/0xcregis/easynode/blockchain/config"
14+
"github.com/0xcregis/easynode/common/util"
1415
"github.com/sunjiangjun/xlog"
1516
"github.com/tidwall/gjson"
1617
)
@@ -256,6 +257,7 @@ func (e *Bnb) GetBlockByNumber(chainCode int64, number string, flag bool) (strin
256257
]
257258
}
258259
`
260+
number, _ = util.Int2Hex(number)
259261
req = fmt.Sprintf(req, number, flag)
260262
return e.SendReq(chainCode, req)
261263
}

blockchain/service/ether/ether.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/0xcregis/easynode/blockchain"
1414
"github.com/0xcregis/easynode/blockchain/chain"
1515
"github.com/0xcregis/easynode/blockchain/config"
16+
"github.com/0xcregis/easynode/common/util"
1617
"github.com/gorilla/websocket"
1718
"github.com/sunjiangjun/xlog"
1819
"github.com/tidwall/gjson"
@@ -275,6 +276,8 @@ func (e *Ether) GetBlockByNumber(chainCode int64, number string, flag bool) (str
275276
]
276277
}
277278
`
279+
280+
number, _ = util.Int2Hex(number)
278281
req = fmt.Sprintf(req, number, flag)
279282
return e.SendReq(chainCode, req)
280283
}

blockchain/service/ether/ether_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ func TestEther_TokenBalance(t *testing.T) {
6060
}
6161
}
6262

63+
func TestEther_Nonce(t *testing.T) {
64+
s := Init()
65+
resp, err := s.Nonce(200, "0xae2Fc483527B8EF99EB5D9B44875F005ba1FaE13", "latest")
66+
if err != nil {
67+
t.Error(err)
68+
} else {
69+
t.Log(resp)
70+
}
71+
}
72+
6373
func TestEther_GetLatestBlock(t *testing.T) {
6474
s := Init()
6575
resp, err := s.LatestBlock(200)

0 commit comments

Comments
 (0)