Documentation
¶
Index ¶
- Variables
- func ManifestFromSegment(header string) (string, error)
- func Root(out, errOut io.Writer) *cobra.Command
- func Serve(parent context.Context, p Params, logOut io.Writer) (result error)
- type Challenge
- type Params
- type PaymentEngine
- func (e *PaymentEngine) Balance(manifest string) (*big.Rat, error)
- func (e *PaymentEngine) ChallengeForManifest(appID, manifest, service string) (Challenge, error)
- func (e *PaymentEngine) ChallengeInfo(manifest string) (wire.OrchestratorInfo, error)
- func (e *PaymentEngine) ChallengePrice(appID, manifest string) (int64, string, error)
- func (e *PaymentEngine) Charge(ctx context.Context, manifest string, now time.Time) (result error)
- func (e *PaymentEngine) MakeChallenge(ctx context.Context, appID, manifest string, payer ethcommon.Address, ...) (challenge Challenge, result error)
- func (e *PaymentEngine) PruneControlState(ctx context.Context) error
- func (e *PaymentEngine) Receive(ctx context.Context, appID, manifest, paymentHeader, segmentHeader string) (payerResult ethcommon.Address, credit *big.Rat, result error)
- func (e *PaymentEngine) RefreshChallenge(ctx context.Context, manifest string, payer ethcommon.Address, service string) (challenge Challenge, result error)
- type RedeemerDB
- type Registry
- func (r *Registry) AddStatic(config StaticRunner) error
- func (r *Registry) CheckStaticHealth(ctx context.Context, client *http.Client)
- func (r *Registry) Close()
- func (r *Registry) Counts() (runners, sessions int)
- func (r *Registry) Discovery() []discoveryEntry
- func (r *Registry) Expire()
- func (r *Registry) Heartbeat(req heartbeatRequest, auth string) (heartbeatResponse, int, error)
- func (r *Registry) ModeForRunner(id string) (string, int, error)
- func (r *Registry) PaidSessions() []string
- func (r *Registry) PriceForRunner(id string) (priceInfo, int, error)
- func (r *Registry) PriceForSession(id, sid string) (priceInfo, int, error)
- func (r *Registry) ReleaseBySession(sid string, reasons ...string)
- func (r *Registry) Reserve(id string) (string, string, string, int, error)
- func (r *Registry) ReserveWithID(id, requestedID string) (string, string, string, int, error)
- func (r *Registry) SetWeiPerUSD(rate *big.Rat)
- func (r *Registry) String() string
- func (r *Registry) Unregister(id, auth string) (int, error)
- type Server
- type StaticRunner
Constants ¶
This section is empty.
Variables ¶
var ErrFixedAlreadyCharged = errors.New("fixed-price session already charged")
var ErrInsufficientBalance = errors.New("insufficient payment balance")
var ErrInvalidPayment = errors.New("invalid payment")
var ErrMissingChallenge = errors.New("payment challenge not found")
Functions ¶
func ManifestFromSegment ¶
Types ¶
type Params ¶
type Params struct {
ConfigFile string `` /* 151-byte string literal not displayed */
nodeconfig.Settings
Account *ethcommon.Address `descr:"Keystore account address"`
OrchestratorAddress *ethcommon.Address `descr:"Registered orchestrator address receiving ticket payments; defaults to the keystore account"`
ETHUSDFeed *ethcommon.Address `name:"eth-usd-feed" descr:"ETH/USD oracle address, alternative to a fixed wei-per-usd rate"`
PriceMaxAge time.Duration `default:"2h" descr:"Maximum age of the oracle observation"`
Listen boa.HTTPBind `default:"127.0.0.1:8935" descr:"Public HTTP listener"`
MetricsListen boa.HTTPBind `default:"127.0.0.1:8936" descr:"Metrics listener"`
ServiceURL boa.Text[*url.URL] `optional:"true" descr:"Public orchestrator base URL; defaults to http://listen"`
APIOriginURL boa.Text[*url.URL] `optional:"true" descr:"Client API Host as a URL; defaults to service-url"`
RunnerServiceURL boa.Text[*url.URL] `optional:"true" descr:"Runner-facing base URL for callbacks and trickle; defaults to service-url"`
ProxyURLTemplate string `optional:"true" descr:"Generated proxy URL with {proxy} in a hostname label or final path segment"`
ExcludedHeaders []string `optional:"true" descr:"Headers to remove from app requests; a trailing * matches a prefix"`
ExcludedCookies []string `optional:"true" descr:"Cookie names to remove from app requests; matching is case-sensitive"`
BootstrapSecret string `secret:"true" optional:"true" descr:"Dynamic runner bootstrap credential"`
BootstrapSecretFile string `basepath:"source" secretfor:"BootstrapSecret" descr:"File containing runner bootstrap credential"`
RunnerConfig string `basepath:"source" optional:"true" file:"true" descr:"Static runner TOML path"`
RedeemerURL *url.URL `name:"redeemer-url" optional:"true" descr:"Remote winning-ticket redeemer base URL"`
RedeemerHeaders nodeconfig.Headers `optional:"true" secret:"true" descr:"Headers authenticating winning-ticket submission"`
RedeemerHeadersFile string `basepath:"source" secretfor:"RedeemerHeaders" descr:"Owner-only ticket submission headers file"`
RedeemerGrants []string `optional:"true" descr:"Private remote redeemer IP[:port] or CIDR grants"`
MaxPendingTickets int `default:"100000" min:"1" descr:"Maximum unsettled winning tickets"`
MaxTicketsPerRecipient int `default:"10000" min:"1" descr:"Maximum unsettled tickets per recipient"`
RedeemerDB string `optional:"true" file:"optional"`
KeystoreFile string `basepath:"source" optional:"true" descr:"Encrypted geth redemption account JSON file"`
KeystorePassword *string `secret:"true" optional:"true" descr:"Keystore decryption password"`
KeystorePasswordFile string `basepath:"source" secretfor:"KeystorePassword" descr:"Owner-only file containing the exact keystore password bytes"`
RPCURL *url.URL `name:"rpc-url" secret:"true" optional:"true"`
RPCURLFile string `basepath:"source" name:"rpc-url-file" secretfor:"RPCURL"`
ChainID *uint64 `min:"1"`
RedeemerTxTimeout time.Duration `default:"5m" descr:"Inclusion timeout for each redemption transaction attempt"`
RedeemerMaxTxReplacements int `default:"1" min:"0" descr:"Maximum fee replacements per redemption attempt"`
RedeemerMaxFeePerGas *uint256.Int `descr:"Optional maximum redemption fee in wei per gas"`
Controller *ethcommon.Address `name:"controller-address"`
WeiPerUSD *big.Rat
TicketFaceValue *uint256.Int
TicketWinProb *uint256.Int
RunnerGrants []string `optional:"true" descr:"Private runner IP[:port] or CIDR grants"`
SessionProxyGrants []string `optional:"true" descr:"Private session proxy IP[:port] or CIDR grants"`
HealthGrants []string `optional:"true" descr:"Private static runner health IP[:port] or CIDR grants"`
HeartbeatInterval time.Duration `default:"5s" descr:"Runner heartbeat interval"`
HeartbeatTTL time.Duration `default:"30s" descr:"Runner heartbeat expiry"`
DrainTimeout time.Duration `default:"12h" descr:"Maximum app drain time after withdrawal, from 0 to 12h; zero ends work immediately"`
PrintConfig bool `optional:"true" boa:"noconfig,noenv" descr:"Print audited redacted TOML configuration"`
}
type PaymentEngine ¶
type PaymentEngine struct {
// contains filtered or unexported fields
}
PaymentEngine owns process-local payment challenges and session accounting. Winning tickets and redemption state are durable in the orchestrator redeemer.
func NewPaymentEngine ¶
func NewPaymentEngine(store *RedeemerDB, chain pm.PaymentChain, recipient ethcommon.Address, faceValue, winProb *big.Int) (*PaymentEngine, error)
func (*PaymentEngine) ChallengeForManifest ¶
func (e *PaymentEngine) ChallengeForManifest(appID, manifest, service string) (Challenge, error)
func (*PaymentEngine) ChallengeInfo ¶
func (e *PaymentEngine) ChallengeInfo(manifest string) (wire.OrchestratorInfo, error)
func (*PaymentEngine) ChallengePrice ¶
func (e *PaymentEngine) ChallengePrice(appID, manifest string) (int64, string, error)
ChallengePrice returns the agreed quote for a pending reservation, scoped to its app registration. App and feed updates must not change a previously issued quote.
func (*PaymentEngine) MakeChallenge ¶
func (e *PaymentEngine) MakeChallenge(ctx context.Context, appID, manifest string, payer ethcommon.Address, price int64, unit, service string) (challenge Challenge, result error)
MakeChallenge returns a Python/Go runner compatible 402 body. Ticket parameters are authenticated by the recipient HMAC.
func (*PaymentEngine) PruneControlState ¶
func (e *PaymentEngine) PruneControlState(ctx context.Context) error
PruneControlState bounds process-local session and nonce state. Winning tickets and uncertain broadcasts remain durable for redemption/recovery.
type RedeemerDB ¶
type RedeemerDB struct {
*redemption.RedeemerDB
// contains filtered or unexported fields
}
RedeemerDB keeps the payment admission adapter alongside the shared queue.
func OpenRedeemerDB ¶
func OpenRedeemerDB(path string) (*RedeemerDB, error)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) AddStatic ¶
func (r *Registry) AddStatic(config StaticRunner) error
func (*Registry) CheckStaticHealth ¶
func (*Registry) PaidSessions ¶
func (*Registry) PriceForRunner ¶
PriceForRunner returns the price for an app registration ID (a runner ID for legacy apps).
func (*Registry) PriceForSession ¶
func (*Registry) ReleaseBySession ¶
func (*Registry) ReserveWithID ¶
func (*Registry) SetWeiPerUSD ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ChargePaidSessions ¶
func (*Server) SetPayment ¶
func (s *Server) SetPayment(engine *PaymentEngine)