You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: storagenode.go
    path of file: ./repos/storj/storagenode/console/consoleapi
    
    the code of the file until where you have to start completion: // Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.

package consoleapi

import (
	"encoding/json"
	"net/http"
	"time"

	"github.com/gorilla/mux"
	"github.com/zeebo/errs"
	"go.uber.org/zap"

	"storj.io/common/storj"
	"storj.io/storj/storagenode/console"
)

// ErrStorageNodeAPI - console storagenode api error type.
var ErrStorageNodeAPI = errs.Class("consoleapi storagenode")

// StorageNode is an api controller that exposes all dashboard related api.
type StorageNode struct {
	service *console.Service

	log *zap.Logger
}

// NewStorageNode is a constructor for sno controller.
func NewStorageNode(log *zap.Logger, service *cons
    
func (dashboard *StorageNode) EstimatedPayout(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	var err error
	defer mon.Task()(&ctx)(&err)

	w.Header().Set(contentType, applicationJSON)

	now := time.Now()

	queryParams := r.URL.Query()
	id := queryParams.Get("id")
	if id == "" {
		data, err := dashboard.service.GetAllSatellitesEstimatedPayout(ctx, now)
		if err != nil {
			dashboard.serveJSONError(w, http.StatusInternalServerError, ErrStorageNodeAPI.Wrap(err))
			return
		}

		if err := json.NewEncoder(w).Encode(data); err != nil {
			dashboard.log.Error("failed to encode json response", zap.Error(ErrPayoutAPI.Wrap(err)))
			return
		}
	} else {
		satelliteID, err := storj.NodeIDFromString(id)
		if err != nil {
			dashboard.serveJSONError(w, http.StatusBadRequest, ErrPayoutAPI.Wrap(err))
			return
		}

		data, err := dashboard.service.GetSatelliteEstimatedPayout(ctx, satelliteID, now)
		if err != nil {
			dashboard.serveJSONError(w, http.StatusInternalServerError, ErrStorageNodeAPI.Wrap(err))
			return
		}

		if err := json.NewEncoder(w).Encode(data); err != nil {
			dashboard.log.Error("failed to encode json response", zap.Error(ErrPayoutAPI.Wrap(err)))
			return
		}
	}
}