<commit_before>package api

import (
	"fmt"
	"net/http"

	"github.com/NebulousLabs/Sia/build"
	"github.com/NebulousLabs/Sia/types"
)

// The ConsensusGET struct contains general information about the consensus
// set, with tags to support idiomatic json encodings.
type ConsensusGET struct {
	Height       types.BlockHeight `json:"height"`
	CurrentBlock types.BlockID     `json:"currentBlock"`
	Target       types.Target      `json:"target"`
}

// consensusHandlerGET handles a GET request to /consensus.
func (srv *Server) consensusHandlerGET(w http.ResponseWriter, req *http.Request) {
	id := srv.mu.RLock()
	defer srv.mu.RUnlock(id)

	curblockID := srv.currentBlock.ID()
	currentTarget, exists := srv.cs.ChildTarget(curblockID)
	if build.DEBUG {
		if !exists {
			fmt.Printf("Could not find block %s\n", curblockID)
			panic("server has nonexistent current block")
		}
	}

	writeJSON(w, ConsensusGET{
		Height:       types.BlockHeight(srv.blockchainHeight),
		CurrentBlock: srv.currentBlock.ID(),
		Target:       currentTarget,
	})
}

// consensusHandler handles the API calls to /consensus.
func (srv *Server) consensusHandler(w http.ResponseWriter, req *http.Request) {
	if req.Method == "" || req.Method == "GET" {
		srv.consensusHandlerGET(w, req)<commit_msg>remove json tags from ConsensusGET<commit_after>package api

import (
	"fmt"
	"net/http"

	"github.com/NebulousLabs/Sia/build"
	"github.com/NebulousLabs/Sia/types"
)

// The ConsensusGET struct contains general information about the consensus
// set, with tags to support idiomatic json encodings.
type ConsensusGET struct {
	Height       types.BlockHeight
	CurrentBlock types.BlockID
	Target       types.Target
}

// consensusHandlerGET handles a GET request to /consensus.
func (srv *Server) consensusHandlerGET(w http.ResponseWriter, req *http.Request) {
	id := srv.mu.RLock()
	defer srv.mu.RUnlock(id)

	curblockID := srv.currentBlock.ID()
	currentTarget, exists := srv.cs.ChildTarget(curblockID)
	if build.DEBUG {
		if !exists {
			fmt.Printf("Could not find block %s\n", curblockID)
			panic("server has nonexistent current block")
		}
	}

	writeJSON(w, ConsensusGET{
		Height:       types.BlockHeight(srv.blockchainHeight),
		CurrentBlock: srv.currentBlock.ID(),
		Target:       currentTarget,
	})
}

// consensusHandler handles the API calls to /consensus.
func (srv *Server) consensusHandler(w http.ResponseWriter, req *http.Request) {
	if req.Method == "" || req.Method == "GET" {
		srv.consensusHandlerGET(w, req)
{'fraction_non_alphanumeric': 0.1176706827309237, 'fraction_numerical': 0.0, 'mean_word_length': 4.1360824742268045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '59772', 'n_tokens_mistral': 845, 'n_tokens_neox': 815, 'n_words': 204}