* Change --gas=0 semantic in order to enable gas auto estimate. * REST clients have been modified to simulate the execution of the tx first to then populate the context with the estimated gas amount returned by the simulation. * The simulation returns both an unadjusted gas estimate and an adjusted one. The adjustment is required to ensure that the ensuing execution doesn't fail due to state changes that might have occurred. Gas adjustment can be controlled via the CLI's --gas-adjustment flag. * Tiny refactorig of REST endpoints error handling. Closes: #1246
13 lines
266 B
Go
13 lines
266 B
Go
package utils
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
// WriteErrorResponse prepares and writes a HTTP error
|
|
// given a status code and an error message.
|
|
func WriteErrorResponse(w *http.ResponseWriter, status int, msg string) {
|
|
(*w).WriteHeader(status)
|
|
(*w).Write([]byte(msg))
|
|
}
|