lotus api 调用 不念不忘少年蓝@ 2022-10-17 04:12 114阅读 0赞 lotus https://github.com/filecoin-project/lotus lotus 基本文档 https://docs.lotu.sh/ 两个Lotus节点+矿工API https://github.com/filecoin-project/lotus/blob/master/api/api\_common.go Lotus节点API https://github.com/filecoin-project/lotus/blob/master/api/api\_full.go Lotus Miner API https://github.com/filecoin-project/lotus/blob/master/api/api\_storage.go func ChainHead()(jsonstr string,err error) \{ song := make(map\[string\]interface\{\}) song\["jsonrpc"\] = "2.0" song\["method"\] = "Filecoin.ChainHead" song\["id"\] = 3 bytesData, err := json.Marshal(song) if err != nil \{ return "",err \} reader := bytes.NewReader(bytesData) request, err := http.NewRequest("POST", "http://127.0.0.1:1234/rpc/v0", reader) if err != nil \{ fmt.Println(err.Error()) return "",err \} request.Header.Set("Content-Type", "application/json;charset=UTF-8") client := http.Client\{\} resp, err := client.Do(request) if err != nil \{ fmt.Println(err.Error()) return "",err \} respBytes, err := ioutil.ReadAll(resp.Body) if err != nil \{ fmt.Println(err.Error()) return "",err \} //byte数组直接转成string,优化内存 str := (\*string)(unsafe.Pointer(&respBytes)) return \*str,nil \}
还没有评论,来说两句吧...