Documentation ¶
Index ¶
- Constants
- Variables
- func AddMinerToServiceTypeMapping(db db.DB, serviceType uint64, minerAddr string) error
- func AddOrUpdateMinerStatus(db db.DB, address string, status uint8) error
- func AddServiceRequest(db db.DB, serviceID, minerID string, height int64) error
- func BuildKeyForClientRegistration(ethereumAddress string) []byte
- func BuildKeyForMinerJob(minerID string) []byte
- func BuildKeyForMinerRating(minerAddress string) []byte
- func BuildKeyForMinerRegistration(ethereumAddress string) []byte
- func BuildServiceTypeKey(serviceType uint64) []byte
- func GenerateHashForServiceInfo(clientAddress string, metadata []byte, blockHeight int64) string
- func GetClientRating(db db.DB, minerAddress string) (map[string]uint8, error)
- func GetMinerStatus(db db.DB, address string) (uint8, error)
- func GetMinersForServiceType(db db.DB, serviceType uint64) ([]string, error)
- func InitKVStore(app *PersistentKVStoreApplication)
- func MakeValSetChangeTx(pubkey pc.PublicKey, power int64) []byte
- func RandVal(i int) types.ValidatorUpdate
- func RandVals(cnt int) []types.ValidatorUpdate
- func RegisterMiner(db db.DB, miner MinerInfo, minerAddress string) error
- func RemoveJobInfo(db db.DB, minerID string, serviceID string) error
- func RemoveMinerFromServiceTypeMapping(db db.DB, serviceType uint64, minerAddr string) error
- func RemoveMinerStatus(db db.DB, address string) error
- func RemoveServiceRequest(db db.DB, serviceID string) error
- func RetainServiceRequestsAboveHeight(db db.DB, retainHeight int64) error
- func SaveMinerStatuses(db db.DB, statuses MinerStatuses) error
- func SaveServiceRequests(db db.DB, requests ServiceRequests) error
- func StoreClientInfo(db db.DB, ethereumAddress string, info ClientInfo) error
- func StoreClientRating(db db.DB, minerAddress string, ratings map[string]uint8) error
- func StoreJobInfo(db db.DB, minerID string, newJob JobInfo) error
- func StoreMinerInfo(db db.DB, ethereumAddress string, info MinerInfo) error
- func StoreMinersForServiceType(db db.DB, serviceType uint64, miners []string) error
- type Application
- func (app *Application) ApplySnapshotChunk(req types.RequestApplySnapshotChunk) types.ResponseApplySnapshotChunk
- func (app *Application) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock
- func (app *Application) CheckTx(req types.RequestCheckTx) types.ResponseCheckTx
- func (app *Application) Commit() types.ResponseCommit
- func (app *Application) DeliverTx(req types.RequestDeliverTx) types.ResponseDeliverTx
- func (app *Application) EndBlock(req types.RequestEndBlock) types.ResponseEndBlock
- func (app *Application) Info(req types.RequestInfo) (resInfo types.ResponseInfo)
- func (app *Application) ListSnapshots(req types.RequestListSnapshots) types.ResponseListSnapshots
- func (app *Application) LoadSnapshotChunk(req types.RequestLoadSnapshotChunk) types.ResponseLoadSnapshotChunk
- func (app *Application) OfferSnapshot(req types.RequestOfferSnapshot) types.ResponseOfferSnapshot
- func (app *Application) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery)
- func (app *Application) SetLogger(l log.Logger)
- func (app *Application) SetOption(req types.RequestSetOption) types.ResponseSetOption
- func (app *Application) Validators() (validators []types.ValidatorUpdate)
- type BlockServices
- type ClientInfo
- type JobInfo
- type MinerInfo
- type MinerServices
- type MinerStatuses
- type MinerWorkRecords
- func (mwr *MinerWorkRecords) AddOrUpdateRecord(newBlock BlockServices) error
- func (mwr MinerWorkRecords) FindByHeight(height int64) (int, bool)
- func (mwr *MinerWorkRecords) IncrementServiceType(height int64, minerID string, serviceType uint64) error
- func (mwr *MinerWorkRecords) UpdateMinerServices(height int64, minerServices MinerServices) error
- type PersistentKVStoreApplication
- func (app *PersistentKVStoreApplication) ApplySnapshotChunk(req types.RequestApplySnapshotChunk) types.ResponseApplySnapshotChunk
- func (app *PersistentKVStoreApplication) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock
- func (app *PersistentKVStoreApplication) CheckTx(req types.RequestCheckTx) types.ResponseCheckTx
- func (app *PersistentKVStoreApplication) Commit() types.ResponseCommit
- func (app *PersistentKVStoreApplication) DeliverTx(req types.RequestDeliverTx) types.ResponseDeliverTx
- func (app *PersistentKVStoreApplication) EndBlock(req types.RequestEndBlock) types.ResponseEndBlock
- func (app *PersistentKVStoreApplication) Info(req types.RequestInfo) types.ResponseInfo
- func (app *PersistentKVStoreApplication) InitChain(req types.RequestInitChain) types.ResponseInitChain
- func (app *PersistentKVStoreApplication) ListSnapshots(req types.RequestListSnapshots) types.ResponseListSnapshots
- func (app *PersistentKVStoreApplication) LoadSnapshotChunk(req types.RequestLoadSnapshotChunk) types.ResponseLoadSnapshotChunk
- func (app *PersistentKVStoreApplication) OfferSnapshot(req types.RequestOfferSnapshot) types.ResponseOfferSnapshot
- func (app *PersistentKVStoreApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery)
- func (app *PersistentKVStoreApplication) SetLogger(l log.Logger)
- func (app *PersistentKVStoreApplication) SetOption(req types.RequestSetOption) types.ResponseSetOption
- func (app *PersistentKVStoreApplication) Validators() (validators []types.ValidatorUpdate)
- type ServiceRequest
- type ServiceRequests
- type ServiceTypeCount
- type State
Constants ¶
const ( Stale uint8 = iota Ready Busy )
const ( Registered uint8 = 0 // Indicates an initial state or condition Processing uint8 = 1 // Indicates a state where processing is underway )
Additional constants for specific application states
const (
ValidatorSetChangePrefix string = "val:"
)
Variables ¶
var (
ProtocolVersion uint64 = 0x1
)
Functions ¶
func AddMinerToServiceTypeMapping ¶
AddMinerToServiceTypeMapping adds a miner's address to the service type mapping in the database.
func AddOrUpdateMinerStatus ¶
AddOrUpdateMinerStatus adds a new miner or updates an existing miner's status.
func AddServiceRequest ¶
func BuildKeyForClientRegistration ¶
BuildKey generates a database key for a given Ethereum address.
func BuildKeyForMinerJob ¶
BuildKeyForMinerJob generates a database key for a given miner's job.
func BuildKeyForMinerRating ¶
BuildKeyForMinerRating generates a database key for a given miner's address.
func BuildKeyForMinerRegistration ¶
BuildKeyForMinerRegistration generates a database key for a given Ethereum address.
func BuildServiceTypeKey ¶
BuildServiceTypeKey generates a database key for service type mappings.
func GenerateHashForServiceInfo ¶
GenerateHashForMinerInfo creates a unique hash for given miner information which includes the miner's address, any relevant metadata, and the block height.
func GetClientRating ¶
GetClientRating retrieves the map of client ratings from the database using the miner's address.
func GetMinerStatus ¶
GetMinerStatus queries a single miner's status.
func GetMinersForServiceType ¶
GetMinersForServiceType retrieves the list of miners for a given service type from the database.
func InitKVStore ¶
func InitKVStore(app *PersistentKVStoreApplication)
InitKVStore initializes the kvstore app with some data, which allows tests to pass and is fine as long as you don't make any tx that modify the validator state
func RandVal ¶
func RandVal(i int) types.ValidatorUpdate
RandVal creates one random validator, with a key derived from the input value
func RandVals ¶
func RandVals(cnt int) []types.ValidatorUpdate
RandVals returns a list of cnt validators for initializing the application. Note that the keys are deterministically derived from the index in the array, while the power is random (Change this if not desired)
func RegisterMiner ¶
RegisterMiner registers a new miner and updates the service type mappings in the database.
func RemoveJobInfo ¶
RemoveJobInfo removes a JobInfo from the list stored in the database under the miner's ID based on the ServiceID.
func RemoveMinerFromServiceTypeMapping ¶
RemoveMinerFromServiceTypeMapping removes a miner's address from the service type mapping in the database.
func RemoveMinerStatus ¶
RemoveMinerStatus removes a miner's status from the map.
func SaveMinerStatuses ¶
func SaveMinerStatuses(db db.DB, statuses MinerStatuses) error
SaveMinerStatuses helper to store the entire map in the database.
func SaveServiceRequests ¶
func SaveServiceRequests(db db.DB, requests ServiceRequests) error
func StoreClientInfo ¶
func StoreClientInfo(db db.DB, ethereumAddress string, info ClientInfo) error
StoreClientInfo stores ClientInfo in the database under the key derived from the Ethereum address.
func StoreClientRating ¶
StoreClientRating stores the map of client ratings in the database under the key derived from the miner's address.
func StoreJobInfo ¶
StoreJobInfo updates or appends a JobInfo in the list stored in the database under the miner's ID.
func StoreMinerInfo ¶
StoreMinerInfo stores MinerInfo in the database under the key derived from the Ethereum address.
Types ¶
type Application ¶
type Application struct { types.BaseApplication RetainBlocks int64 // blocks to retain after commit (via ResponseCommit.RetainHeight) // validator set ValUpdates []types.ValidatorUpdate // contains filtered or unexported fields }
func NewApplication ¶
func NewApplication(dbDir string) *Application
func (*Application) ApplySnapshotChunk ¶
func (app *Application) ApplySnapshotChunk( req types.RequestApplySnapshotChunk) types.ResponseApplySnapshotChunk
func (*Application) BeginBlock ¶
func (app *Application) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock
Track the block hash and header information
func (*Application) CheckTx ¶
func (app *Application) CheckTx(req types.RequestCheckTx) types.ResponseCheckTx
func (*Application) Commit ¶
func (app *Application) Commit() types.ResponseCommit
func (*Application) DeliverTx ¶
func (app *Application) DeliverTx(req types.RequestDeliverTx) types.ResponseDeliverTx
tx is either "key=value" or just arbitrary bytes
func (*Application) EndBlock ¶
func (app *Application) EndBlock(req types.RequestEndBlock) types.ResponseEndBlock
Update the validator set
func (*Application) Info ¶
func (app *Application) Info(req types.RequestInfo) (resInfo types.ResponseInfo)
func (*Application) ListSnapshots ¶
func (app *Application) ListSnapshots( req types.RequestListSnapshots) types.ResponseListSnapshots
func (*Application) LoadSnapshotChunk ¶
func (app *Application) LoadSnapshotChunk( req types.RequestLoadSnapshotChunk) types.ResponseLoadSnapshotChunk
func (*Application) OfferSnapshot ¶
func (app *Application) OfferSnapshot( req types.RequestOfferSnapshot) types.ResponseOfferSnapshot
func (*Application) Query ¶
func (app *Application) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery)
Returns an associated value or nil if missing.
func (*Application) SetLogger ¶
func (app *Application) SetLogger(l log.Logger)
func (*Application) SetOption ¶
func (app *Application) SetOption(req types.RequestSetOption) types.ResponseSetOption
func (*Application) Validators ¶
func (app *Application) Validators() (validators []types.ValidatorUpdate)
type BlockServices ¶
type BlockServices struct { BlockHeight int64 `json:"block_height"` MinerServices []MinerServices `json:"miner_services"` }
BlockServices holds the block height and a list of miner services provided at that height.
type ClientInfo ¶
func GetClientInfo ¶
func GetClientInfo(db db.DB, ethereumAddress string) (ClientInfo, error)
GetClientInfo retrieves ClientInfo from the database using the Ethereum address.
type JobInfo ¶
type JobInfo struct { ServiceID string `json:"service_id"` // The unique identifier for the service ClientID string `json:"client_id"` // The identifier of the client requesting the service ServiceType uint64 `json:"service_type"` // The numeric identifier of the type of service JobStatus uint8 `json:"job_status"` // The status of the job TimeoutBlock int64 `json:"timeout_block"` // The block index when the job will expire }
JobInfo represents information about a specific job or task associated with a service.
func GetJobInfoByServiceID ¶
GetJobInfoByServiceID retrieves a single JobInfo by ServiceID from a specified miner's list of jobs.
type MinerInfo ¶
type MinerInfo struct { Name string // The name of the miner Power uint64 // The computational power of the miner, possibly in hashes per second ServiceTypes []uint64 // An array of service type identifiers that the miner provides IP string // The IP address of the miner for network connections InitialStatus uint8 }
type MinerServices ¶
type MinerServices struct { MinerID string `json:"miner_id"` ServiceTypes ServiceTypeCount `json:"service_types"` }
MinerServices contains a miner ID and a map of service types with their respective counts.
type MinerStatuses ¶
func LoadMinerStatuses ¶
func LoadMinerStatuses(db db.DB) (MinerStatuses, error)
LoadMinerStatuses helper to retrieve the entire map from the database.
type MinerWorkRecords ¶
type MinerWorkRecords []BlockServices
MinerWorkRecords manages a collection of BlockServices, tracking services provided by miners over time.
func (*MinerWorkRecords) AddOrUpdateRecord ¶
func (mwr *MinerWorkRecords) AddOrUpdateRecord(newBlock BlockServices) error
func (MinerWorkRecords) FindByHeight ¶
func (mwr MinerWorkRecords) FindByHeight(height int64) (int, bool)
func (*MinerWorkRecords) IncrementServiceType ¶
func (mwr *MinerWorkRecords) IncrementServiceType(height int64, minerID string, serviceType uint64) error
func (*MinerWorkRecords) UpdateMinerServices ¶
func (mwr *MinerWorkRecords) UpdateMinerServices(height int64, minerServices MinerServices) error
type PersistentKVStoreApplication ¶
type PersistentKVStoreApplication struct { // validator set ValUpdates []types.ValidatorUpdate // contains filtered or unexported fields }
func NewPersistentKVStoreApplication ¶
func NewPersistentKVStoreApplication(dbDir string) *PersistentKVStoreApplication
func (*PersistentKVStoreApplication) ApplySnapshotChunk ¶
func (app *PersistentKVStoreApplication) ApplySnapshotChunk( req types.RequestApplySnapshotChunk) types.ResponseApplySnapshotChunk
func (*PersistentKVStoreApplication) BeginBlock ¶
func (app *PersistentKVStoreApplication) BeginBlock(req types.RequestBeginBlock) types.ResponseBeginBlock
Track the block hash and header information
func (*PersistentKVStoreApplication) CheckTx ¶
func (app *PersistentKVStoreApplication) CheckTx(req types.RequestCheckTx) types.ResponseCheckTx
func (*PersistentKVStoreApplication) Commit ¶
func (app *PersistentKVStoreApplication) Commit() types.ResponseCommit
Commit will panic if InitChain was not called
func (*PersistentKVStoreApplication) DeliverTx ¶
func (app *PersistentKVStoreApplication) DeliverTx(req types.RequestDeliverTx) types.ResponseDeliverTx
tx is either "val:pubkey!power" or "key=value" or just arbitrary bytes
func (*PersistentKVStoreApplication) EndBlock ¶
func (app *PersistentKVStoreApplication) EndBlock(req types.RequestEndBlock) types.ResponseEndBlock
Update the validator set
func (*PersistentKVStoreApplication) Info ¶
func (app *PersistentKVStoreApplication) Info(req types.RequestInfo) types.ResponseInfo
func (*PersistentKVStoreApplication) InitChain ¶
func (app *PersistentKVStoreApplication) InitChain(req types.RequestInitChain) types.ResponseInitChain
Save the validators in the merkle tree
func (*PersistentKVStoreApplication) ListSnapshots ¶
func (app *PersistentKVStoreApplication) ListSnapshots( req types.RequestListSnapshots) types.ResponseListSnapshots
func (*PersistentKVStoreApplication) LoadSnapshotChunk ¶
func (app *PersistentKVStoreApplication) LoadSnapshotChunk( req types.RequestLoadSnapshotChunk) types.ResponseLoadSnapshotChunk
func (*PersistentKVStoreApplication) OfferSnapshot ¶
func (app *PersistentKVStoreApplication) OfferSnapshot( req types.RequestOfferSnapshot) types.ResponseOfferSnapshot
func (*PersistentKVStoreApplication) Query ¶
func (app *PersistentKVStoreApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery)
When path=/val and data={validator address}, returns the validator update (types.ValidatorUpdate) varint encoded. For any other path, returns an associated value or nil if missing.
func (*PersistentKVStoreApplication) SetLogger ¶
func (app *PersistentKVStoreApplication) SetLogger(l log.Logger)
func (*PersistentKVStoreApplication) SetOption ¶
func (app *PersistentKVStoreApplication) SetOption(req types.RequestSetOption) types.ResponseSetOption
func (*PersistentKVStoreApplication) Validators ¶
func (app *PersistentKVStoreApplication) Validators() (validators []types.ValidatorUpdate)
type ServiceRequest ¶
type ServiceRequests ¶
type ServiceRequests []ServiceRequest
func LoadServiceRequests ¶
func LoadServiceRequests(db db.DB) (ServiceRequests, error)
type ServiceTypeCount ¶
ServiceTypeCount maps a service type to the number of times a miner has served that type.