You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
757 B

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