Documentation ¶
Overview ¶
Package daemonPkg handles the chifra daemon command. It manages chifra's API server. Each of the chifra commands along with all of its options, are provided not only by the command line, but also the API server. We call this process the flame server, which is written in Go. chifra serve is an alias for the command. In the future, this daemon may also manage other long-running processes such as chifra scrape and chifra monitors, but for now, it's only managing the API server. The --grpc option turns on a GRPC server that may speed up certain command such as chifra names, although this option is experimental and therefore not recommended for production use. If the default port for the API server is in use, you may change it with the --port option. To get help for any command, please see the API documentation on our website. But, you may also run chifra --help or chifra <cmd> --help on your command line to get help. See below for an example of converting command line options to a call to the API. There's a one-to-one correspondence between the command line tools and options and the API routes and their options.
Index ¶
- Variables
- func ContentTypeHandler(next http.Handler) http.Handler
- func CorsHandler(next http.Handler) http.Handler
- func HandleWebsockets(pool *ConnectionPool, w http.ResponseWriter, r *http.Request)
- func Index(w http.ResponseWriter, r *http.Request)
- func Logger(inner http.Handler, name string) http.Handler
- func NewRouter() *mux.Router
- func ResetOptions(testMode bool)
- func RespondWithError(w http.ResponseWriter, httpStatus int, err error)
- func RouteAbis(w http.ResponseWriter, r *http.Request)
- func RouteBlocks(w http.ResponseWriter, r *http.Request)
- func RouteChunks(w http.ResponseWriter, r *http.Request)
- func RouteConfig(w http.ResponseWriter, r *http.Request)
- func RouteExplore(w http.ResponseWriter, r *http.Request)
- func RouteExport(w http.ResponseWriter, r *http.Request)
- func RouteInit(w http.ResponseWriter, r *http.Request)
- func RouteList(w http.ResponseWriter, r *http.Request)
- func RouteLogs(w http.ResponseWriter, r *http.Request)
- func RouteMonitors(w http.ResponseWriter, r *http.Request)
- func RouteNames(w http.ResponseWriter, r *http.Request)
- func RouteReceipts(w http.ResponseWriter, r *http.Request)
- func RouteScrape(w http.ResponseWriter, r *http.Request)
- func RouteSlurp(w http.ResponseWriter, r *http.Request)
- func RouteState(w http.ResponseWriter, r *http.Request)
- func RouteStatus(w http.ResponseWriter, r *http.Request)
- func RouteTokens(w http.ResponseWriter, r *http.Request)
- func RouteTraces(w http.ResponseWriter, r *http.Request)
- func RouteTransactions(w http.ResponseWriter, r *http.Request)
- func RouteWhen(w http.ResponseWriter, r *http.Request)
- func RunDaemon(cmd *cobra.Command, args []string) error
- func RunWebsocketPool()
- func ServeDaemon(w http.ResponseWriter, r *http.Request) error
- type Connection
- type ConnectionPool
- type DaemonOptions
- type Message
- type MessageType
- type Route
- type Routes
Constants ¶
This section is empty.
Variables ¶
var OptionsHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
addCorsHeaders(w)
})
Functions ¶
func ContentTypeHandler ¶
ContentTypeHandler sets correct Content-Type header on response
func CorsHandler ¶
CorsHandler handles CORS requests
func HandleWebsockets ¶
func HandleWebsockets(pool *ConnectionPool, w http.ResponseWriter, r *http.Request)
HandleWebsockets handles web sockets
func ResetOptions ¶
func ResetOptions(testMode bool)
func RespondWithError ¶
func RespondWithError(w http.ResponseWriter, httpStatus int, err error)
RespondWithError marshals an err into JSON and returns the bytes back to the caller httpStatus HTTP error status code
func RouteAbis ¶
func RouteAbis(w http.ResponseWriter, r *http.Request)
RouteAbis Fetches the ABI for a smart contract.
func RouteBlocks ¶
func RouteBlocks(w http.ResponseWriter, r *http.Request)
RouteBlocks Retrieve one or more blocks from the chain or local cache.
func RouteChunks ¶
func RouteChunks(w http.ResponseWriter, r *http.Request)
RouteChunks Manage, investigate, and display the Unchained Index.
func RouteConfig ¶
func RouteConfig(w http.ResponseWriter, r *http.Request)
RouteConfig Report on and edit the configuration of the TrueBlocks system.
func RouteExplore ¶
func RouteExplore(w http.ResponseWriter, r *http.Request)
RouteExplore Open a local or remote explorer for one or more addresses, blocks, or transactions.
func RouteExport ¶
func RouteExport(w http.ResponseWriter, r *http.Request)
RouteExport Export full details of transactions for one or more addresses.
func RouteInit ¶
func RouteInit(w http.ResponseWriter, r *http.Request)
RouteInit Initialize the TrueBlocks system by downloading the Unchained Index from IPFS.
func RouteList ¶
func RouteList(w http.ResponseWriter, r *http.Request)
RouteList List every appearance of an address anywhere on the chain.
func RouteLogs ¶
func RouteLogs(w http.ResponseWriter, r *http.Request)
RouteLogs Retrieve logs for the given transaction(s).
func RouteMonitors ¶
func RouteMonitors(w http.ResponseWriter, r *http.Request)
RouteMonitors Add, remove, clean, and list address monitors.
func RouteNames ¶
func RouteNames(w http.ResponseWriter, r *http.Request)
RouteNames Query addresses or names of well-known accounts.
func RouteReceipts ¶
func RouteReceipts(w http.ResponseWriter, r *http.Request)
RouteReceipts Retrieve receipts for the given transaction(s).
func RouteScrape ¶
func RouteScrape(w http.ResponseWriter, r *http.Request)
RouteScrape Scan the chain and update the TrueBlocks index of appearances.
func RouteSlurp ¶
func RouteSlurp(w http.ResponseWriter, r *http.Request)
RouteSlurp Fetch data from Etherscan for any address.
func RouteState ¶
func RouteState(w http.ResponseWriter, r *http.Request)
RouteState Retrieve account balance(s) for one or more addresses at given block(s).
func RouteStatus ¶
func RouteStatus(w http.ResponseWriter, r *http.Request)
RouteStatus Report on the state of the internal binary caches.
func RouteTokens ¶
func RouteTokens(w http.ResponseWriter, r *http.Request)
RouteTokens Retrieve token balance(s) for one or more addresses at given block(s).
func RouteTraces ¶
func RouteTraces(w http.ResponseWriter, r *http.Request)
RouteTraces Retrieve traces for the given transaction(s).
func RouteTransactions ¶
func RouteTransactions(w http.ResponseWriter, r *http.Request)
RouteTransactions Retrieve one or more transactions from the chain or local cache.
func RouteWhen ¶
func RouteWhen(w http.ResponseWriter, r *http.Request)
RouteWhen Find block(s) based on date, blockNum, timestamp, or 'special'.
func RunDaemon ¶
RunDaemon handles the daemon command for the command line. Returns error only as per cobra.
func ServeDaemon ¶
func ServeDaemon(w http.ResponseWriter, r *http.Request) error
ServeDaemon handles the daemon command for the API. Returns an error.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a structure representing a websocket connection
func (*Connection) Log ¶
func (c *Connection) Log(s string, args ...interface{})
Log writes a log messages to the server's stderr
func (*Connection) RemoteAddr ¶
func (c *Connection) RemoteAddr() net.Addr
RemoteAddr is the other end of the connection
type ConnectionPool ¶
type ConnectionPool struct {
// contains filtered or unexported fields
}
ConnectionPool is the collection of all connections
type DaemonOptions ¶
type DaemonOptions struct { Url string `json:"url,omitempty"` // Specify the API server's url and optionally its port Api string `json:"api,omitempty"` // Instruct the node to start the API server Scrape string `json:"scrape,omitempty"` // Start the scraper, initialize it with either just blooms or entire index, generate for new blocks Monitor bool `json:"monitor,omitempty"` // Instruct the node to start the monitors tool Grpc bool `json:"grpc,omitempty"` // Run gRPC server to serve names Port string `json:"port,omitempty"` // Deprecated please use --url flag instead Globals globals.GlobalOptions `json:"globals,omitempty"` // The global options Conn *rpc.Connection `json:"conn,omitempty"` // The connection to the RPC server BadFlag error `json:"badFlag,omitempty"` // An error flag if needed }
DaemonOptions provides all command options for the chifra daemon command.
func GetDaemonOptions ¶
func GetDaemonOptions(args []string, g *globals.GlobalOptions) *DaemonOptions
GetDaemonOptions returns the options for this tool so other tools may use it.
func GetOptions ¶
func GetOptions() *DaemonOptions
func (*DaemonOptions) DaemonInternal ¶
func (opts *DaemonOptions) DaemonInternal() error
DaemonInternal handles the internal workings of the daemon command. Returns an error.
func (*DaemonOptions) HandleGrpc ¶
func (opts *DaemonOptions) HandleGrpc() error
func (*DaemonOptions) HandleMonitor ¶
func (opts *DaemonOptions) HandleMonitor() error
HandleMonitor starts and manages the monitor process
func (*DaemonOptions) HandleScraper ¶
func (opts *DaemonOptions) HandleScraper() error
HandleScraper starts and manages the scraper process
func (*DaemonOptions) String ¶
func (opts *DaemonOptions) String() string
String implements the Stringer interface
type Message ¶
type Message struct { Action MessageType `json:"action"` ID string `json:"id"` Content string `json:"content"` }
Message is a structure used to send messages via websockets
type MessageType ¶
type MessageType string
MessageType is a message carried in a string
const ( // CommandErrorMessage is a message send when the server encounters an error CommandErrorMessage MessageType = "command_error" // CommandOutputMessage is currently not used, but may in the future carry the actual data CommandOutputMessage MessageType = "output" // ProgressMessage is a message carried on the stderr stream ProgressMessage MessageType = "progress" )