resourceprovider

package
v2.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2025 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const CONTROL_LOOP_INTERVAL = 10 * time.Second

the background "even if we have not heard of an event" loop i.e. things will not wait 10 seconds - the control loop reacts to events in the system - this 10 second background loop is just for in case we miss any events

View Source
const RESOURCE_OFFER_INTERVAL = 10 * time.Minute

the interval at which we check and post resource offers

Variables

View Source
var MaybeCudaOrCpu = NewCpuWorker

Functions

func DefaultWorkerNum

func DefaultWorkerNum() int

func PostCard

func PostCard(id string, challange string, difficulty string) error

func TriggerNewPowRound

func TriggerNewPowRound(ctx context.Context, web3SDK *web3.Web3SDK) (common.Hash, error)

Types

type CpuWorker

type CpuWorker struct {
	// contains filtered or unexported fields
}

func (*CpuWorker) FindSolution

func (w *CpuWorker) FindSolution(ctx context.Context, task *Task)

func (*CpuWorker) Stop

func (w *CpuWorker) Stop()

type MinerController

type MinerController struct {
	// contains filtered or unexported fields
}

func NewMinerController

func NewMinerController(nodeId string, powCfg ResourceProviderPowOptions, task chan Task, submit SubmitWork) *MinerController

func (*MinerController) Start

func (m *MinerController) Start(ctx context.Context)

type ResourceProvider

type ResourceProvider struct {
	// contains filtered or unexported fields
}

func NewResourceProvider

func NewResourceProvider(
	options ResourceProviderOptions,
	web3SDK *web3.Web3SDK,
	executor executor.Executor,
	tracer trace.Tracer,
) (*ResourceProvider, error)

func (*ResourceProvider) Start

func (resourceProvider *ResourceProvider) Start(ctx context.Context, cm *system.CleanupManager) chan error

func (*ResourceProvider) StartMineLoop

func (resourceProvider *ResourceProvider) StartMineLoop(ctx context.Context) chan error

type ResourceProviderController

type ResourceProviderController struct {
	// contains filtered or unexported fields
}

func NewResourceProviderController

func NewResourceProviderController(
	options ResourceProviderOptions,
	web3SDK *web3.Web3SDK,
	executor executor.Executor,
	tracer trace.Tracer,
) (*ResourceProviderController, error)

func (*ResourceProviderController) Start

func (controller *ResourceProviderController) Start(ctx context.Context, cm *system.CleanupManager) chan error

type ResourceProviderOfferOptions

type ResourceProviderOfferOptions struct {
	// if we are configuring a single machine then
	// these values are populated by the flags
	OfferSpec data.MachineSpec
	// we can dupliate the single spec to create a list of specs
	OfferCount int
	// this represents how many machines we will keep
	// offering to the network
	// we can configure this with a config file
	// to start with we will just add --cpu --gpu and --ram flags
	// to the resource provider CLI which constrains them to a single machine
	Specs []data.MachineSpec
	// the list of modules we are willing to run
	// an empty list means anything
	Modules []string

	// this will normally be FixedPrice for RP's
	Mode data.PricingMode

	// the default pricing for this resource provider
	// for all modules that don't have a specific price
	DefaultPricing data.DealPricing

	// allow different pricing for different modules
	ModulePricing map[string]data.DealPricing

	// which mediators and directories this RP will trust
	Services data.ServiceConfig
}

this configures the resource offers we will keep track of

type ResourceProviderPowOptions

type ResourceProviderPowOptions struct {
	DisablePow         bool
	NumWorkers         int
	CudaGridSize       int
	CudaBlockSize      int
	CudaHashsPerThread int
}

this configures the pow we will keep track of

type SubmitWork

type SubmitWork func(nonce *big.Int, hashrate float64)

type Task

type Task struct {
	Id         uuid.UUID
	Challenge  [32]byte
	Difficulty *uint256.Int
	From       *uint256.Int
	End        *uint256.Int
}

type TaskResult

type TaskResult struct {
	Id    uuid.UUID
	Nonce *uint256.Int
}

type Worker

type Worker interface {
	FindSolution(ctx context.Context, task *Task)
	Stop()
}

func NewCpuWorker

func NewCpuWorker(cfg *WorkerConfig) (Worker, error)

type WorkerConfig

type WorkerConfig struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL