Documentation ¶
Index ¶
- Variables
- func CalculateCID(v interface{}) (string, error)
- func CheckJobOffer(jobOffer JobOffer) error
- func CheckResourceOffer(resourceOffer ResourceOffer) error
- func CheckResult(result Result) error
- func ConvertDealMembers(members DealMembers) controller.SharedStructsDealMembers
- func ConvertDealPricing(pricing DealPricing) controller.SharedStructsDealPricing
- func ConvertDealTimeout(timeout DealTimeout, withCollateral bool) controller.SharedStructsDealTimeout
- func ConvertDealTimeouts(timeouts DealTimeouts) controller.SharedStructsDealTimeouts
- func EtherToWei(etherAmount float64) *big.Int
- func GetAgreementState(itemType string) (uint8, error)
- func GetAgreementStateIndex(itemType string) uint8
- func GetAgreementStateString(itemType uint8) string
- func GetDealID(deal Deal) (string, error)
- func GetDefaultAgreementState() uint8
- func GetJobOfferID(offer JobOffer) (string, error)
- func GetModuleID(module ModuleConfig) (string, error)
- func GetMutualServices(a []string, b []string) []string
- func GetPaymentDirection(itemType string) (uint8, error)
- func GetPaymentReason(itemType string) (uint8, error)
- func GetResourceOfferID(offer ResourceOffer) (string, error)
- func GetServiceType(itemType string) (uint8, error)
- func GetTypeIndex(name string, arr []string, itemType string) (uint8, error)
- func IsActiveAgreementState(itemType uint8) bool
- func IsTerminalAgreementState(itemType uint8) bool
- type Deal
- type DealContainer
- type DealMembers
- type DealPricing
- type DealTimeout
- type DealTimeouts
- type DealTransactions
- type DealTransactionsJobCreator
- type DealTransactionsMediator
- type DealTransactionsResourceProvider
- type JobOffer
- type JobOfferContainer
- type MachineSpec
- type MatchDecision
- type Module
- type ModuleConfig
- type PricingMode
- type ResourceOffer
- type ResourceOfferContainer
- type Result
- type ServiceConfig
Constants ¶
This section is empty.
Variables ¶
var AgreementState = []string{
"DealNegotiating",
"DealAgreed",
"ResultsSubmitted",
"ResultsAccepted",
"ResultsChecked",
"MediationAccepted",
"MediationRejected",
"TimeoutSubmitResults",
"TimeoutJudgeResults",
"TimeoutMediateResults",
}
AgreementState corresponds to AgreementState in TypeScript
var PaymentDirection = []string{
"PaidIn",
"PaidOut",
"Refunded",
"Slashed",
}
PaymentDirection corresponds to PaymentDirection in TypeScript
var PaymentReason = []string{
"PaymentCollateral",
"ResultsCollateral",
"TimeoutCollateral",
"JobPayment",
"MediationFee",
}
PaymentReason corresponds to PaymentReason in TypeScript
var ServiceType = []string{
"Solver",
"Mediator",
"Directory",
"ResourceProvider",
"JobCreator",
}
ServiceType corresponds to ServiceType in TypeScript
Functions ¶
func CalculateCID ¶
CalculateCID takes an interface, serializes it to JSON, and returns its IPFS CID
func CheckJobOffer ¶
func CheckResourceOffer ¶
func CheckResourceOffer(resourceOffer ResourceOffer) error
func CheckResult ¶
func ConvertDealMembers ¶
func ConvertDealMembers( members DealMembers, ) controller.SharedStructsDealMembers
func ConvertDealPricing ¶
func ConvertDealPricing( pricing DealPricing, ) controller.SharedStructsDealPricing
func ConvertDealTimeout ¶
func ConvertDealTimeout( timeout DealTimeout, withCollateral bool, ) controller.SharedStructsDealTimeout
func ConvertDealTimeouts ¶
func ConvertDealTimeouts( timeouts DealTimeouts, ) controller.SharedStructsDealTimeouts
func EtherToWei ¶
func GetAgreementState ¶
GetAgreementState corresponds to getAgreementState in TypeScript
func GetAgreementStateIndex ¶
func GetAgreementStateString ¶
func GetDefaultAgreementState ¶
func GetDefaultAgreementState() uint8
func GetJobOfferID ¶
func GetModuleID ¶
func GetModuleID(module ModuleConfig) (string, error)
func GetMutualServices ¶
func GetPaymentDirection ¶
GetPaymentDirection corresponds to getPaymentDirection in TypeScript
func GetPaymentReason ¶
GetPaymentReason corresponds to getPaymentReason in TypeScript
func GetResourceOfferID ¶
func GetResourceOfferID(offer ResourceOffer) (string, error)
func GetServiceType ¶
GetServiceType corresponds to getServiceType in TypeScript
func GetTypeIndex ¶
GetTypeIndex corresponds to getTypeIndex in TypeScript
func IsActiveAgreementState ¶
Types ¶
type Deal ¶
type Deal struct { // this is the cid of the deal where ID is set to empty string ID string `json:"id"` Members DealMembers `json:"members"` Pricing DealPricing `json:"pricing"` Timeouts DealTimeouts `json:"timeouts"` JobOffer JobOffer `json:"job_offer"` ResourceOffer ResourceOffer `json:"resource_offer"` }
this is the struct that will have it's ID taken and used as the reference for what both parties agreed to the solver will publish this deal to the directory
type DealContainer ¶
type DealContainer struct { ID string `json:"id"` JobCreator string `json:"job_creator"` ResourceProvider string `json:"resource_provider"` JobOffer string `json:"job_offer"` ResourceOffer string `json:"resource_offer"` State uint8 `json:"state"` Deal Deal `json:"deal"` Transactions DealTransactions `json:"transactions"` Mediator string `json:"mediator"` }
func GetDealContainer ¶
func GetDealContainer( deal Deal, ) DealContainer
type DealMembers ¶
type DealPricing ¶
type DealTimeout ¶
type DealTimeouts ¶
type DealTimeouts struct { Agree DealTimeout `json:"agree"` SubmitResults DealTimeout `json:"submit_results"` JudgeResults DealTimeout `json:"judge_results"` MediateResults DealTimeout `json:"mediate_results"` }
type DealTransactions ¶
type DealTransactions struct { ResourceProvider DealTransactionsResourceProvider `json:"resource_provider"` JobCreator DealTransactionsJobCreator `json:"job_creator"` Mediator DealTransactionsMediator `json:"mediator"` }
type DealTransactionsJobCreator ¶
type DealTransactionsJobCreator struct { Agree string `json:"agree"` AcceptResult string `json:"accept_result"` CheckResult string `json:"check_result"` TimeoutAgree string `json:"timeout_agree"` TimeoutSubmitResult string `json:"timeout_submit_result"` TimeoutMediateResult string `json:"timeout_mediate_result"` }
we keep track of tx ids on behalf of resource providers and job creators - we use these to "marK" a deal as having had a transaction submitted but that tx has not yet been included in a block - therefore, we let the job creator & resource provider update these at will
type JobOffer ¶
type JobOffer struct { // this is the cid of the job offer where ID is set to empty string ID string `json:"id"` // this is basically a nonce so we don't have one ID pointing at multiple offers CreatedAt int `json:"created_at"` // the address of the job creator JobCreator string `json:"job_creator"` // the actual module that is being offered // this must hash to the ModuleID above Module ModuleConfig `json:"module"` // the spec required by the module // this will have been hoisted from the module itself Spec MachineSpec `json:"spec"` // the user inputs to the module // these values will power the go template Inputs map[string]string `json:"inputs"` // tells the solver how to match these prices // for JC this will normally be MarketPrice Mode PricingMode `json:"mode"` // the offered price and timeouts Pricing DealPricing `json:"pricing"` Timeouts DealTimeouts `json:"timeouts"` // which parties are trusted by the job creator Services ServiceConfig `json:"trusted_parties"` }
posted to the solver by a job creator
type JobOfferContainer ¶
type JobOfferContainer struct { ID string `json:"id"` DealID string `json:"deal_id"` JobCreator string `json:"job_creator"` State uint8 `json:"state"` JobOffer JobOffer `json:"job_offer"` }
this is what the solver keeps track of so we can know what the current state of the deal is
func GetJobOfferContainer ¶
func GetJobOfferContainer( jobOffer JobOffer, ) JobOfferContainer
type MachineSpec ¶
type MachineSpec struct { // Milli-GPU // Whilst it's unlikely that partial GPU's make sense // let's not use a float and fix the precision to 1/1000 GPU int `json:"gpu"` // Milli-CPU CPU int `json:"cpu"` // Megabytes RAM int `json:"ram"` }
used by resource providers to describe their resources use by job offers to describe their requirements when used by resource providers - these are absolute values when used by job offers - these are minimum requirements
type MatchDecision ¶
type MatchDecision struct { JobOffer string `json:"job_offer"` ResourceOffer string `json:"resource_offer"` Deal string `json:"deal"` Result bool `json:"result"` }
represents a solver decision the solver keeps track of "no" decisions to avoid trying to repeatedly match things it's already decided it can't match
type Module ¶
type Module struct { // the min spec that this module requires // e.g. does this module need a GPU? // the module file itself will contain this spec // and so the module will need to be downloaded // and executed for this spec to be known Machine MachineSpec `json:"machine"` // the bacalhau job spec Job bacalhau.Job `json:"job"` }
this is what is loaded from the template file in the git repo
type ModuleConfig ¶
type ModuleConfig struct { // used for the shortcuts // this is in the modules package // where we keep a map of named modules // and their versions onto the // repo, hash and path below Name string `json:"name"` // needs to be a http url for a git repo // we must be able to clone it without credentials Repo string `json:"repo"` // the git hash to pin the module // we will 'git checkout' this hash Hash string `json:"hash"` // once the checkout has been done // this is the path to the module template // within the repo Path string `json:"path"` }
describes a workload to be run this pins a go-template.yaml file that is a bacalhau job spec
type PricingMode ¶
type PricingMode string
MarketPrice means - get me the best deal job creators will do this by default i.e. "just buy me the cheapest" FixedPrice means - take it or leave it resource creators will do this by default i.e. "this is my price"
const ( MarketPrice PricingMode = "MarketPrice" FixedPrice PricingMode = "FixedPrice" )
type ResourceOffer ¶
type ResourceOffer struct { // this is the cid of the resource offer where ID is set to empty string ID string `json:"id"` // this is basically a nonce so we don't have one ID pointing at multiple offers CreatedAt int `json:"created_at"` // the address of the job creator ResourceProvider string `json:"resource_provider"` // allows a resource provider to manage multiple offers // that are essentially the same Index int `json:"index"` // the spec being offered Spec MachineSpec `json:"spec"` // the module ID's that this resource provider can run // an empty list means ALL modules Modules []string `json:"modules"` // tells the solver how to match these prices // for RP this will normally be FixedPrice // we expect the default pricing to be filled in Mode PricingMode `json:"mode"` // the default pricing for this resource offer // i.e. this is for any module DefaultPricing DealPricing `json:"default_pricing"` DefaultTimeouts DealTimeouts `json:"default_timeouts"` // the pricing for each module // this allows a resource provider to charge more // for certain modules ModulePricing map[string]DealPricing `json:"module_pricing"` ModuleTimeouts map[string]DealTimeouts `json:"module_timeouts"` // which parties are trusted by the resource provider Services ServiceConfig `json:"trusted_parties"` }
posted to the solver by a resource provider
type ResourceOfferContainer ¶
type ResourceOfferContainer struct { ID string `json:"id"` DealID string `json:"deal_id"` ResourceProvider string `json:"resource_provider"` State uint8 `json:"state"` ResourceOffer ResourceOffer `json:"job_offer"` }
this is what the solver keeps track of so we can know what the current state of the deal is
func GetResourceOfferContainer ¶
func GetResourceOfferContainer( resourceOffer ResourceOffer, ) ResourceOfferContainer
type ServiceConfig ¶
the mediator and directory services that are trusted by the RP and JC - the solver will find an intersection of these and attach them to the deal