arnaucube
arnaucube/blockchainIDsystemPublic Self-hosted repository
blockchainIDsystem/serverCA/blockchainRESTFunctions.go
serverCA/blockchainRESTFunctions.goRaw
 1package main
 2
 3import (
 4	"encoding/json"
 5	"fmt"
 6	"net/http"
 7)
 8
 9type Address struct {
10	Address string `json:"address"` //the pubK of the user, to perform logins
11}
12
13func Index(w http.ResponseWriter, r *http.Request) {
14	fmt.Fprintln(w, "CA")
15}
16func GetPeers(w http.ResponseWriter, r *http.Request) {
17	getPeers()
18
19	jResp, err := json.Marshal(peersList)
20	check(err)
21	fmt.Fprintln(w, string(jResp))
22}
23
24func GetBlockchain(w http.ResponseWriter, r *http.Request) {
25	fmt.Print("aaaaa: ")
26	fmt.Println(blockchain.Blocks[len(blockchain.Blocks)-1].Hash)
27	reconstructBlockchainFromBlock("http://"+config.IP+":"+config.ServerRESTPort, blockchain.Blocks[len(blockchain.Blocks)-1].Hash)
28
29	jResp, err := json.Marshal(blockchain)
30	check(err)
31	fmt.Fprintln(w, string(jResp))
32}