Documentation ¶
Overview ¶
Package core implements Chain Core and its API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupSubmittedTxs ¶
CleanupSubmittedTxs will periodically delete records of submitted txs older than a day. This function blocks and only exits when its context is cancelled.
TODO(jackson): unexport this and start it in a goroutine in a core.New() function?
func Configure ¶
Configure configures the core by writing to the database. If running in a cored process, the caller must ensure that the new configuration is properly reloaded, for example by restarting the process.
If c.IsSigner is true, Configure generates a new mockhsm keypair for signing blocks, and assigns it to c.BlockPub.
If c.IsGenerator is true, Configure creates an initial block, saves it, and assigns its hash to c.BlockchainID. Otherwise, c.IsGenerator is false, and Configure makes a test request to GeneratorURL to detect simple configuration mistakes.
func WriteHTTPError ¶
func WriteHTTPError(ctx context.Context, w http.ResponseWriter, err error)
WriteHTTPError writes a json encoded detailedError to the ResponseWriter. It uses the status code associated with the error.
Types ¶
type Config ¶
type Config struct { ID string `json:"id"` IsSigner bool `json:"is_signer"` IsGenerator bool `json:"is_generator"` BlockchainID bc.Hash `json:"blockchain_id"` GeneratorURL string `json:"generator_url"` GeneratorAccessToken string `json:"generator_access_token"` ConfiguredAt time.Time BlockPub string `json:"block_pub"` Signers []ConfigSigner `json:"block_signer_urls"` Quorum int MaxIssuanceWindow time.Duration }
Config encapsulates Core-level, persistent configuration options.
type ConfigSigner ¶
type Handler ¶
type Handler struct { Chain *protocol.Chain Store *txdb.Store Assets *asset.Registry Accounts *account.Manager HSM *mockhsm.HSM Indexer *query.Indexer Config *Config DB pg.DB Addr string AltAuth func(*http.Request) bool Signer func(context.Context, *bc.Block) ([]byte, error) RequestLimits []RequestLimit // contains filtered or unexported fields }
Handler serves the Chain HTTP API
func (*Handler) HealthSetter ¶
HealthSetter returns a function that, when called, sets the named health status in the map returned by "/health". The returned function is safe to call concurrently with ServeHTTP.
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. |
utxodb
Package utxodb implements UTXO selection and reservation.
|
Package utxodb implements UTXO selection and reservation. |
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 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 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. |