mirror of
https://github.com/arnaucube/blockchainIDsystem.git
synced 2026-02-07 19:16:43 +01:00
added GetBlockchain in REST API of the serverCA, also added the visualization to the serverCA webapp
This commit is contained in:
@@ -21,6 +21,12 @@ var routes = Routes{
|
||||
"/peers",
|
||||
GetPeers,
|
||||
},
|
||||
Route{
|
||||
"GetBlockchain",
|
||||
"GET",
|
||||
"/blockchain",
|
||||
GetBlockchain,
|
||||
},
|
||||
}
|
||||
|
||||
type Address struct {
|
||||
@@ -37,3 +43,13 @@ func GetPeers(w http.ResponseWriter, r *http.Request) {
|
||||
check(err)
|
||||
fmt.Fprintln(w, string(jResp))
|
||||
}
|
||||
|
||||
func GetBlockchain(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Print("aaaaa: ")
|
||||
fmt.Println(blockchain.Blocks[len(blockchain.Blocks)-1].Hash)
|
||||
reconstructBlockchainFromBlock("http://"+config.IP+":"+config.ServerRESTPort, blockchain.Blocks[len(blockchain.Blocks)-1].Hash)
|
||||
|
||||
jResp, err := json.Marshal(blockchain)
|
||||
check(err)
|
||||
fmt.Fprintln(w, string(jResp))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user