Last active
January 1, 2016 13:48
-
-
Save benjiqq/8153138 to your computer and use it in GitHub Desktop.
print blocks
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
/* | |
blockhash 0 is 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f | |
blockhash 1 is 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 | |
blockhash 2 is 000000006a625f06636b8bb6ac7b960a8d03705d1ace08b1a19da3fdcc99ddbd | |
blockhash 3 is 0000000082b5015589a3fdf2d4baff403e6f0be035a5d9742c1cae6295464449 | |
blockhash 4 is 000000004ebadb55ee9096c9a2f8880e09da59c0d68b1c228da88e48844a1485 | |
blockhash 5 is 000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc | |
blockhash 6 is 000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d | |
blockhash 7 is 0000000071966c2b1d065fd446b1e485b2c9d9594acd2007ccbd5441cfc89444 | |
blockhash 8 is 00000000408c48f847aa786c2268fc3e6ec2af68e8468a34a28c61b7f1de0dc6 | |
blockhash 9 is 000000008d9dc510f23c2657fc4f67bea30078cc05a90eb89e84cc475c080805 | |
2013/12/27 22:49:23 elapsed 1.051766 secs | |
*/ | |
package main | |
import ( | |
"fmt" | |
"github.com/conformal/btcjson" | |
"io/ioutil" | |
"log" | |
"testing" | |
"time" | |
) | |
func printblock(){ | |
certFile, err := ioutil.ReadFile("/home/user/.btcd/rpc.cert") | |
if err != nil { | |
log.Fatal(err) | |
} | |
user := "zzz" | |
password := "abc" | |
server := "127.0.0.1:8334" | |
for j := 0; j < 10; j++ { | |
gethashCmd, err := btcjson.NewGetBlockHashCmd(1, int64(j)) | |
if err != nil { | |
log.Fatal(err) | |
} | |
msg, err := gethashCmd.MarshalJSON() | |
if err != nil { | |
log.Fatal(err) | |
} | |
reply, err := btcjson.TlsRpcCommand(user, password, server, msg, certFile, false) | |
if err != nil { | |
log.Fatal(err) | |
} | |
if reply.Error != nil { | |
log.Fatal(reply.Error) | |
} | |
fmt.Printf("blockhash %d is %s\n", j, reply.Result) | |
} | |
} | |
func BenchmarkFunction(b *testing.B) { | |
printblock() | |
} | |
func main() { | |
//br := testing.Benchmark(BenchmarkFunction) | |
startTime := time.Now() | |
//fmt.Println(br) | |
printblock() | |
elapsed := time.Since(startTime) | |
log.Printf("elapsed %f secs\n", elapsed.Seconds()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment