Documentation ¶
Overview ¶
Package core implements Chain Core and its API.
Index ¶
- Constants
- Variables
- func AuthHandler(handler http.Handler, sdb *sinkdb.DB, ...) http.Handler
- func CheckConfigMaybeExec(ctx context.Context, sdb *sinkdb.DB, nodeAddr string)
- func Config(ctx context.Context, db pg.DB, sdb *sinkdb.DB) (*config.Options, error)
- func RedirectHandler(next http.Handler) http.Handler
- func TLSConfig(certFile, keyFile, rootCAs string) (*tls.Config, error)
- type API
- type RunOption
- func BlockSigner(signFn func(context.Context, *legacy.Block) ([]byte, error)) RunOption
- func GeneratorLocal(gen *generator.Generator) RunOption
- func GeneratorRemote(client *rpc.Client) RunOption
- func IndexTransactions(b bool) RunOption
- func MockHSM(hsm *mockhsm.HSM) RunOption
- func RateLimit(keyFn func(*http.Request) string, burst, perSecond int) RunOption
- func UseTLS(c *tls.Config) RunOption
Constants ¶
const GrantPrefix = "/core/grant/"
Variables ¶
var ErrNoTLS = errors.New("no TLS configuration available")
var Policies = []string{
"client-readwrite",
"client-readonly",
"crosscore",
"crosscore-signblock",
"monitoring",
"internal",
"public",
}
Functions ¶
func AuthHandler ¶
func CheckConfigMaybeExec ¶
func Config ¶
Config provides access to Chain Core configuration options and their values.
TODO(jackson): Remove the pg.DB argument when the PostgreSQL url is stored in a configuration option.
func RedirectHandler ¶
RedirectHandler redirects / to /dashboard/.
func TLSConfig ¶
TLSConfig returns a TLS config suitable for use as a Chain Core client and server. It reads a PEM-encoded X.509 certificate and private key from certFile and keyFile. If rootCAs is given, it should name a file containing a list of trusted root CA certs, otherwise the returned config uses the system cert pool.
For compatibility, it attempts to read the cert and key from the environment if certFile and keyFile both do not exist in the filesystem.
TLSCRT=[PEM-encoded X.509 certificate] TLSKEY=[PEM-encoded X.509 private key]
If certFile and keyFile do not exist or are empty and the environment vars are both unset, TLSConfig returns ErrNoTLS.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API serves the Chain HTTP API
func Run ¶
func Run( ctx context.Context, confOpts *config.Options, conf *config.Config, db pg.DB, dbURL string, sdb *sinkdb.DB, c *protocol.Chain, store *txdb.Store, routableAddress string, opts ...RunOption, ) (*API, error)
Run launches a new configured Chain Core. It will start goroutines for the various Core subsystems and enter leader election. It will not start listening for HTTP requests. To begin serving HTTP requests, use API.Handler to retrieve an http.Handler that can be used in a call to http.ListenAndServe.
Either the GeneratorLocal or the GeneratorRemote RunOption is required.
func RunUnconfigured ¶
func RunUnconfigured(ctx context.Context, confOpts *config.Options, db pg.DB, sdb *sinkdb.DB, routableAddress string, opts ...RunOption) *API
RunUnconfigured launches a new unconfigured Chain Core. This is used for Chain Core Developer Edition to expose the configuration UI in the dashboard. API authentication still applies to an unconfigured Chain Core.
type RunOption ¶
type RunOption func(*API)
RunOption describes a runtime configuration option.
func BlockSigner ¶
BlockSigner configures the Core to use signFn to handle block-signing requests. In production, this will be a function to call out to signerd and its HSM. In development, it'll use the MockHSM.
func GeneratorLocal ¶
GeneratorLocal configures the launched Core to run as a Generator.
func GeneratorRemote ¶
GeneratorRemote configures the launched Core to fetch blocks from the provided remote generator.
func IndexTransactions ¶
IndexTransactions configures whether or not transactions should be annotated and indexed for the query engine.
func MockHSM ¶
MockHSM configures the Core to expose the MockHSM endpoints. It is only included in non-production builds.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package accesstoken provides storage and validation of Chain Core credentials.
|
Package accesstoken provides storage and validation of Chain Core credentials. |
Package account stores and tracks accounts within a Chain Core.
|
Package account stores and tracks accounts within a Chain Core. |
Package asset maintains a registry of all assets on a blockchain.
|
Package asset maintains a registry of all assets on a blockchain. |
Package blocksigner implements remote block signing.
|
Package blocksigner implements remote block signing. |
Package config manages persistent configuration data for Chain Core.
|
Package config manages persistent configuration data for Chain Core. |
internal/configpb
Package configpb is a generated protocol buffer package.
|
Package configpb is a generated protocol buffer package. |
Package coretest provides utilities for testing Chain Core.
|
Package coretest provides utilities for testing Chain Core. |
Package coreunsafe contains Core logic that is unsafe for production.
|
Package coreunsafe contains Core logic that is unsafe for production. |
Package fetch implements block replication for participant Chain Cores.
|
Package fetch implements block replication for participant Chain Cores. |
Package generator implements the Chain Core generator.
|
Package generator implements the Chain Core generator. |
Package leader implements leader election between cored processes of a Chain Core.
|
Package leader implements leader election between cored processes of a Chain Core. |
Package migrate implements database migration for Chain Core.
|
Package migrate implements database migration for Chain Core. |
Package mockhsm provides a mock HSM for development environments.
|
Package mockhsm provides a mock HSM for development environments. |
Package query implements indexing and querying of annotated blockchain data.
|
Package query implements indexing and querying of annotated blockchain data. |
filter
Package filter parses and evaluates Chain filter expressions.
|
Package filter parses and evaluates Chain filter expressions. |
Package rpc implements Chain Core's RPC client.
|
Package rpc implements Chain Core's RPC client. |
Package signers associates signers and their corresponding keys.
|
Package signers associates signers and their corresponding keys. |
Package txbuilder builds a Chain Protocol transaction from a list of actions.
|
Package txbuilder builds a Chain Protocol transaction from a list of actions. |
Package txdb provides storage for Chain Protocol blockchain data structures.
|
Package txdb provides storage for Chain Protocol blockchain data structures. |
internal/storage
Package storage is a generated protocol buffer package.
|
Package storage is a generated protocol buffer package. |
Package txfeed implements Chain Core's transaction feeds.
|
Package txfeed implements Chain Core's transaction feeds. |