Skip to content

Commit 1b62b0f

Browse files
committed
feat(): fix GetBlockHashList api
1 parent fa798b7 commit 1b62b0f

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

client.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,11 @@ func (c *Client) GetPendingTxIds() ([]string, error) {
534534
return res, nil
535535
}
536536

537-
func (c *Client) GetBlockHashList() ([]string, error) {
538-
body, statusCode, err := c.httpGet("/hash_list")
537+
func (c *Client) GetBlockHashList(from, to int) ([]string, error) {
538+
if from > to {
539+
return nil, errors.New("from must <= to")
540+
}
541+
body, statusCode, err := c.httpGet("/hash_list/" + strconv.Itoa(from) + "/" + strconv.Itoa(to))
539542
if statusCode != 200 {
540543
return nil, errors.New("get block hash list failed")
541544
}

client_test.go

+28
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,31 @@ func TestNewTempConn(t *testing.T) {
277277
t.Logf("offset: %s, peer: %s", offset.Offset, peer)
278278
}
279279
}
280+
281+
func TestClient_GetBlockHashList(t *testing.T) {
282+
c := NewClient("https://arweave.net")
283+
from := 1095730
284+
to := 1095750
285+
list, err := c.GetBlockHashList(from, to)
286+
assert.NoError(t, err)
287+
t.Log(list)
288+
}
289+
290+
func TestClient_GetBlockHashList2(t *testing.T) {
291+
// c := NewClient("https://arweave.net")
292+
// peers, err := c.GetPeers()
293+
// assert.NoError(t, err)
294+
// pNode := NewTempConn()
295+
// for _, peer := range peers {
296+
// pNode.SetTempConnUrl("http://" + peer)
297+
// from := 1095740
298+
// to := 1095750
299+
// list, err := c.GetBlockHashList(from, to)
300+
// if err != nil {
301+
// t.Log("err", err, "perr", peer)
302+
// continue
303+
// }
304+
// t.Log(peer)
305+
// t.Log(list)
306+
// }
307+
}

0 commit comments

Comments
 (0)