Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var APIHost = "localhost:8099"
Functions ¶
func MapToObject ¶
func MapToObject(source interface{}, dst interface{}) error
func Respond ¶
func Respond(w http.ResponseWriter, response PostResponse)
Types ¶
type APIServer ¶
type APIServer struct {
Statistics *mining.GlobalStatTracker
Server *http.Server
Grader *opr.QuickGrader
Balances *balances.BalanceTracker
Mux *http.ServeMux
// contains filtered or unexported fields
}
APIServer as the base handler
func NewApiServer ¶
func NewApiServer(grader *opr.QuickGrader, balances *balances.BalanceTracker, config *config.Config) *APIServer
type BlockRange ¶
BlockRange specifies a range of directory blocks with a start and end height (inclusive) Negative numbers indicate a request for that many blocks behind the current head
type Error ¶
type Error struct {
Code int `json:"code"`
Reason string `json:"reason"`
Data interface{} `json:"data"`
}
Error struct returns a code and it's associated message 0: <Success> 1: Method Not Found 2: Parameter Not Found 3: Error Decoding JSON 4: Internal Error
func NewInternalError ¶
func NewInternalError() *Error
NewInternalError returns when a bug creeps in
func NewInvalidParametersError ¶
func NewInvalidParametersError() *Error
NewInvalidParameterError returns when the method is valid but the parameter is not
func NewJSONDecodingError ¶
func NewJSONDecodingError() *Error
NewJSONDecodingError returns when the request body is unable to be parsed
func NewMethodNotFoundError ¶
func NewMethodNotFoundError() *Error
NewMethodNotFoundError returns when the specified RPC method is not found
type GenericParameters ¶
type GenericParameters struct {
Address *string `json:"address,omitempty"`
Height *int64 `json:"height,omitempty"`
DigitalID string `json:"miner_id,omitempty"`
Hash string `json:"hash,omitempty"`
}
Parameters contains all possible json inputs TODO: move into separate parameter structs depending on the request type
type GenericResult ¶
type GenericResult struct {
Balance int64 `json:"balance,omitempty"`
Balances map[string]map[[32]byte]int64 `json:"balances,omitempty"`
ChainID string `json:"chain_id,omitempty"`
LeaderHeight int64 `json:"leader_height,omitempty"`
OPRBlocks []*opr.OprBlock `json:"opr_blocks,omitempty"`
Winners []string `json:"winners,omitempty"`
Winner string `json:"winner,omitempty"`
OPRBlock *opr.OprBlock `json:"opr_block,omitempty"`
OPRs []opr.OraclePriceRecord `json:"oprs,omitempty"`
OPR *opr.OraclePriceRecord `json:"opr,omitempty"`
}
Result struct contains all potential json api responses TODO: move into separate parameter structs depending on the response type
type PerformanceParameters ¶
type PerformanceParameters struct {
BlockRange BlockRange `json:"block_range"`
DigitalID string `json:"miner_id,omitempty"`
}
type PerformanceResult ¶
type PostRequest ¶
type PostRequest struct {
Method string `json:"method"`
Params interface{} `json:"params"`
}
PostRequest struct to deserialise from request body
type PostResponse ¶
type PostResponse struct {
Res interface{} `json:"result"`
Err *Error `json:"error"`
}
PostResponse to either contain a valid result or error
func SendRequest ¶
func SendRequest(req *PostRequest) (*PostResponse, error)
SendRequest will send a PostRequest object to the local API server and return the PostResponse