40 lines
840 B
Go
40 lines
840 B
Go
// Package models provides the models for the KermaGo application
|
|
package models
|
|
|
|
import "github.com/docker/go/canonical/json"
|
|
|
|
/*
|
|
A Generic represents a struct that only has a type
|
|
*/
|
|
type Generic struct {
|
|
Type string `json:"type" binding:"required"`
|
|
}
|
|
|
|
/*
|
|
MarshalJson returns the canonical json of the generic object
|
|
*/
|
|
func (g *Generic) MarshalJson() ([]byte, error) {
|
|
return json.MarshalCanonical(g)
|
|
}
|
|
|
|
/*
|
|
BuildPeerRequest creates a new generic object with type "getpeers"
|
|
*/
|
|
func (g *Generic) BuildPeerRequest() {
|
|
g.Type = "getpeers"
|
|
}
|
|
|
|
/*
|
|
BuildChainTipRequest creates a new generic object with type "getchaintip"
|
|
*/
|
|
func (g *Generic) BuildChainTipRequest() {
|
|
g.Type = "getchaintip"
|
|
}
|
|
|
|
/*
|
|
BuildMempoolRequest creates a new generic object with type "getmempool"
|
|
*/
|
|
func (g *Generic) BuildMempoolRequest() {
|
|
g.Type = "getmempool"
|
|
}
|