mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Merge pull request #247 from kanoi/master
api.c data structure + updated get_api_stats/driver-icarus.c
This commit is contained in:
commit
2ec0fb9793
14
API-README
14
API-README
@ -309,13 +309,23 @@ miner.php - an example web page to access the API
|
|||||||
Feature Changelog for external applications using the API:
|
Feature Changelog for external applications using the API:
|
||||||
|
|
||||||
|
|
||||||
API V1.13
|
API V1.14
|
||||||
|
|
||||||
|
Modified API commands:
|
||||||
|
'stats' - more icarus timing stats added
|
||||||
|
|
||||||
|
The internal code for handling data was rewritten (~25% of the code)
|
||||||
|
Completely backward compatible
|
||||||
|
|
||||||
|
----------
|
||||||
|
|
||||||
|
API V1.13 (cgminer v2.4.4)
|
||||||
|
|
||||||
Added API commands:
|
Added API commands:
|
||||||
'check'
|
'check'
|
||||||
|
|
||||||
Support was added to cgminer for API access groups with the --api-groups option
|
Support was added to cgminer for API access groups with the --api-groups option
|
||||||
It's 100% backwards compatible with previous --api-access commands
|
It's 100% backward compatible with previous --api-access commands
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
@ -676,23 +676,30 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|||||||
return hash_count;
|
return hash_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void icarus_api_stats(char *buf, struct cgpu_info *cgpu, bool isjson)
|
static struct api_data *icarus_api_stats(struct cgpu_info *cgpu)
|
||||||
{
|
{
|
||||||
|
struct api_data *root = NULL;
|
||||||
struct ICARUS_INFO *info = icarus_info[cgpu->device_id];
|
struct ICARUS_INFO *info = icarus_info[cgpu->device_id];
|
||||||
|
|
||||||
// Warning, access to these is not locked - but we don't really
|
// Warning, access to these is not locked - but we don't really
|
||||||
// care since hashing performance is way more important than
|
// care since hashing performance is way more important than
|
||||||
// locking access to displaying API debug 'stats'
|
// locking access to displaying API debug 'stats'
|
||||||
sprintf(buf, isjson
|
// If locking becomes an issue for any of them, use copy_data=true also
|
||||||
? "\"read_count\":%d,\"fullnonce\":%f,\"count\":%d,\"Hs\":%.15f,\"W\":%f,\"total_values\":%u,\"range\":%"PRIu64",\"history_count\":%"PRIu64",\"history_time\":%f,\"min_data_count\":%u,\"timing_values\":%u"
|
root = api_add_int(root, "read_count", &(info->read_count), false);
|
||||||
: "read_count=%d,fullnonce=%f,count=%d,Hs=%.15f,W=%f,total_values=%u,range=%"PRIu64",history_count=%"PRIu64",history_time=%f,min_data_count=%u,timing_values=%u",
|
root = api_add_double(root, "fullnonce", &(info->fullnonce), false);
|
||||||
info->read_count, info->fullnonce,
|
root = api_add_int(root, "count", &(info->count), false);
|
||||||
info->count, info->Hs, info->W,
|
root = api_add_hs(root, "Hs", &(info->Hs), false);
|
||||||
info->values, info->hash_count_range,
|
root = api_add_double(root, "W", &(info->W), false);
|
||||||
info->history_count,
|
root = api_add_uint(root, "total_values", &(info->values), false);
|
||||||
(double)(info->history_time.tv_sec)
|
root = api_add_uint64(root, "range", &(info->hash_count_range), false);
|
||||||
+ ((double)(info->history_time.tv_usec))/((double)1000000),
|
root = api_add_uint64(root, "history_count", &(info->history_count), false);
|
||||||
info->min_data_count, info->history[0].values);
|
root = api_add_timeval(root, "history_time", &(info->history_time), false);
|
||||||
|
root = api_add_uint(root, "min_data_count", &(info->min_data_count), false);
|
||||||
|
root = api_add_uint(root, "timing_values", &(info->history[0].values), false);
|
||||||
|
root = api_add_const(root, "timing_mode", timing_mode_str(info->timing_mode), false);
|
||||||
|
root = api_add_bool(root, "is_timing", &(info->do_icarus_timing), false);
|
||||||
|
|
||||||
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void icarus_shutdown(struct thr_info *thr)
|
static void icarus_shutdown(struct thr_info *thr)
|
||||||
|
54
miner.h
54
miner.h
@ -220,6 +220,7 @@ struct gpu_adl {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct api_data;
|
||||||
struct thr_info;
|
struct thr_info;
|
||||||
struct work;
|
struct work;
|
||||||
|
|
||||||
@ -234,7 +235,7 @@ struct device_api {
|
|||||||
void (*reinit_device)(struct cgpu_info*);
|
void (*reinit_device)(struct cgpu_info*);
|
||||||
void (*get_statline_before)(char*, struct cgpu_info*);
|
void (*get_statline_before)(char*, struct cgpu_info*);
|
||||||
void (*get_statline)(char*, struct cgpu_info*);
|
void (*get_statline)(char*, struct cgpu_info*);
|
||||||
void (*get_api_stats)(char*, struct cgpu_info*, bool);
|
struct api_data *(*get_api_stats)(struct cgpu_info*);
|
||||||
|
|
||||||
// Thread-specific functions
|
// Thread-specific functions
|
||||||
bool (*thread_prepare)(struct thr_info*);
|
bool (*thread_prepare)(struct thr_info*);
|
||||||
@ -793,4 +794,55 @@ extern bool successful_connect;
|
|||||||
extern void adl(void);
|
extern void adl(void);
|
||||||
extern void app_restart(void);
|
extern void app_restart(void);
|
||||||
|
|
||||||
|
enum api_data_type {
|
||||||
|
API_ESCAPE,
|
||||||
|
API_STRING,
|
||||||
|
API_CONST,
|
||||||
|
API_INT,
|
||||||
|
API_UINT,
|
||||||
|
API_UINT32,
|
||||||
|
API_UINT64,
|
||||||
|
API_DOUBLE,
|
||||||
|
API_ELAPSED,
|
||||||
|
API_BOOL,
|
||||||
|
API_TIMEVAL,
|
||||||
|
API_TIME,
|
||||||
|
API_MHS,
|
||||||
|
API_MHTOTAL,
|
||||||
|
API_TEMP,
|
||||||
|
API_UTILITY,
|
||||||
|
API_FREQ,
|
||||||
|
API_VOLTS,
|
||||||
|
API_HS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct api_data {
|
||||||
|
enum api_data_type type;
|
||||||
|
char *name;
|
||||||
|
void *data;
|
||||||
|
bool data_was_malloc;
|
||||||
|
struct api_data *prev;
|
||||||
|
struct api_data *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct api_data *api_add_escape(struct api_data *root, char *name, char *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_string(struct api_data *root, char *name, char *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_const(struct api_data *root, char *name, const char *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_int(struct api_data *root, char *name, int *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_uint(struct api_data *root, char *name, unsigned int *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_uint32(struct api_data *root, char *name, uint32_t *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_uint64(struct api_data *root, char *name, uint64_t *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_double(struct api_data *root, char *name, double *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_elapsed(struct api_data *root, char *name, double *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_bool(struct api_data *root, char *name, bool *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_timeval(struct api_data *root, char *name, struct timeval *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_time(struct api_data *root, char *name, time_t *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_mhs(struct api_data *root, char *name, double *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_mhstotal(struct api_data *root, char *name, double *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_temp(struct api_data *root, char *name, float *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_utility(struct api_data *root, char *name, double *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_freq(struct api_data *root, char *name, double *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_volts(struct api_data *root, char *name, float *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_hs(struct api_data *root, char *name, double *data, bool copy_data);
|
||||||
|
|
||||||
#endif /* __MINER_H__ */
|
#endif /* __MINER_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user