Last active
May 9, 2019 19:20
-
-
Save enddynayn/82aa4bf7a1805fcdd5606b86cc6b015b to your computer and use it in GitHub Desktop.
Infura block number toggle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"encoding/json" | |
"net/http" | |
"io/ioutil" | |
"bytes" | |
"time" | |
) | |
type message struct { | |
Jsonrpc string `json: jsonrpc` | |
Method string `json: method` | |
Id int `json: id` | |
Params []int `json: params` | |
} | |
func main() { | |
for i := 0; i < 1000; i++ { | |
post() | |
} | |
} | |
func post() { | |
values := message { | |
Jsonrpc: "2.0", | |
Method: "eth_blockNumber", | |
Id: 1, | |
Params: []int{}, | |
} | |
contentType := "application/json" | |
url := "https://ropsten.infura.io/v3/618c19bf6e0f49939f287bfa66a4e71c" | |
jsonValue, _ := json.Marshal(values) | |
resp, err := http.Post(url, contentType, bytes.NewBuffer(jsonValue)) | |
if err != nil { | |
fmt.Println("=( !!") | |
return | |
} | |
body_byte, err := ioutil.ReadAll(resp.Body) | |
fmt.Printf("%v", time.Now()) | |
fmt.Println(string(body_byte)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment