|
@ -1,7 +1,6 @@ |
|
|
package main |
|
|
package main |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"fmt" |
|
|
|
|
|
"log" |
|
|
"log" |
|
|
"net/http" |
|
|
"net/http" |
|
|
"os" |
|
|
"os" |
|
@ -20,6 +19,7 @@ var dateCountCollection *mgo.Collection |
|
|
var hourCountCollection *mgo.Collection |
|
|
var hourCountCollection *mgo.Collection |
|
|
|
|
|
|
|
|
func main() { |
|
|
func main() { |
|
|
|
|
|
savelog() |
|
|
//read goBlockchainDataAbalysis config
|
|
|
//read goBlockchainDataAbalysis config
|
|
|
readConfig("config.json") |
|
|
readConfig("config.json") |
|
|
|
|
|
|
|
@ -33,50 +33,46 @@ func main() { |
|
|
dateCountCollection = getCollection(session, "dateCounts") |
|
|
dateCountCollection = getCollection(session, "dateCounts") |
|
|
hourCountCollection = getCollection(session, "hourCounts") |
|
|
hourCountCollection = getCollection(session, "hourCounts") |
|
|
|
|
|
|
|
|
// create new client instance
|
|
|
|
|
|
client, err := btcrpcclient.New(&btcrpcclient.ConnConfig{ |
|
|
|
|
|
HTTPPostMode: true, |
|
|
|
|
|
DisableTLS: true, |
|
|
|
|
|
Host: config.Host + ":" + config.Port, |
|
|
|
|
|
User: config.User, |
|
|
|
|
|
Pass: config.Pass, |
|
|
|
|
|
}, nil) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Fatalf("error creating new btc client: %v", err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// list accounts
|
|
|
|
|
|
accounts, err := client.ListAccounts() |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Fatalf("error listing accounts: %v", err) |
|
|
|
|
|
} |
|
|
|
|
|
// iterate over accounts (map[string]btcutil.Amount) and write to stdout
|
|
|
|
|
|
for label, amount := range accounts { |
|
|
|
|
|
log.Printf("%s: %s", label, amount) |
|
|
|
|
|
} |
|
|
|
|
|
if len(os.Args) > 1 { |
|
|
if len(os.Args) > 1 { |
|
|
if os.Args[1] == "-explore" { |
|
|
if os.Args[1] == "-explore" { |
|
|
|
|
|
// create new client instance
|
|
|
|
|
|
client, err := btcrpcclient.New(&btcrpcclient.ConnConfig{ |
|
|
|
|
|
HTTPPostMode: true, |
|
|
|
|
|
DisableTLS: true, |
|
|
|
|
|
Host: config.Host + ":" + config.Port, |
|
|
|
|
|
User: config.User, |
|
|
|
|
|
Pass: config.Pass, |
|
|
|
|
|
}, nil) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Fatalf("error creating new btc client: %v", err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// list accounts
|
|
|
|
|
|
accounts, err := client.ListAccounts() |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Fatalf("error listing accounts: %v", err) |
|
|
|
|
|
} |
|
|
|
|
|
// iterate over accounts (map[string]btcutil.Amount) and write to stdout
|
|
|
|
|
|
for label, amount := range accounts { |
|
|
|
|
|
log.Printf("%s: %s", label, amount) |
|
|
|
|
|
} |
|
|
color.Blue("starting to explore blockchain") |
|
|
color.Blue("starting to explore blockchain") |
|
|
explore(client, config.GenesisBlock) |
|
|
explore(client, config.GenesisBlock) |
|
|
} |
|
|
|
|
|
/*if os.Args[1] == "-tree" { |
|
|
|
|
|
color.Blue("starting to make tree") |
|
|
|
|
|
addressTree(client, "fY3HZxu7HFKRcYzVSTXRZpAJMP4qba2oR6") |
|
|
|
|
|
}*/ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Get the current block count.
|
|
|
|
|
|
blockCount, err := client.GetBlockCount() |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Fatal(err) |
|
|
|
|
|
|
|
|
// Get the current block count.
|
|
|
|
|
|
blockCount, err := client.GetBlockCount() |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Fatal(err) |
|
|
|
|
|
} |
|
|
|
|
|
log.Printf("Block count: %d", blockCount) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
log.Printf("Block count: %d", blockCount) |
|
|
|
|
|
|
|
|
|
|
|
//http server start
|
|
|
//http server start
|
|
|
readServerConfig("./serverConfig.json") |
|
|
readServerConfig("./serverConfig.json") |
|
|
color.Green("server running") |
|
|
|
|
|
fmt.Print("port: ") |
|
|
|
|
|
color.Green(serverConfig.ServerPort) |
|
|
|
|
|
|
|
|
log.Println("server running") |
|
|
|
|
|
log.Print("port: ") |
|
|
|
|
|
log.Println(serverConfig.ServerPort) |
|
|
router := NewRouter() |
|
|
router := NewRouter() |
|
|
|
|
|
|
|
|
headersOk := handlers.AllowedHeaders([]string{"X-Requested-With", "Access-Control-Allow-Origin"}) |
|
|
headersOk := handlers.AllowedHeaders([]string{"X-Requested-With", "Access-Control-Allow-Origin"}) |
|
|