Skip to content

Commit

Permalink
add json header
Browse files Browse the repository at this point in the history
  • Loading branch information
nosequeldeebee committed Mar 2, 2018
1 parent 29abe28 commit 37611d5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions proof-work/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func handleWriteBlock(w http.ResponseWriter, r *http.Request) {
}
defer r.Body.Close()

//ensure atomicity when creating new block
mutex.Lock()
newBlock, err := generateBlock(Blockchain[len(Blockchain)-1], m.BPM)
if err != nil {
Expand All @@ -127,6 +128,7 @@ func handleWriteBlock(w http.ResponseWriter, r *http.Request) {
}

func respondWithJSON(w http.ResponseWriter, r *http.Request, code int, payload interface{}) {
w.Header().Set("Content-Type", "application/json")
response, err := json.MarshalIndent(payload, "", " ")
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Expand Down

0 comments on commit 37611d5

Please sign in to comment.