44#include "cJSON.h"
55#include <stdint.h>
66#include <stdbool.h>
7+ #include <sys/time.h>
8+ #include <esp_transport.h>
79
810#define MAX_MERKLE_BRANCHES 32
911#define HASH_SIZE 32
1012#define COINBASE_SIZE 100
1113#define COINBASE2_SIZE 128
14+ #define MAX_REQUEST_IDS 1024
15+ #define MAX_EXTRANONCE_2_LEN 32
1216
1317typedef enum
1418{
1519 STRATUM_UNKNOWN ,
1620 MINING_NOTIFY ,
1721 MINING_SET_DIFFICULTY ,
1822 MINING_SET_VERSION_MASK ,
23+ MINING_SET_EXTRANONCE ,
24+ MINING_PING ,
1925 STRATUM_RESULT ,
2026 STRATUM_RESULT_SETUP ,
2127 STRATUM_RESULT_VERSION_MASK ,
2228 STRATUM_RESULT_SUBSCRIBE ,
2329 CLIENT_RECONNECT
2430} stratum_method ;
2531
32+ typedef enum
33+ {
34+ DISABLED = 0 ,
35+ BUNDLED_CRT = 1 ,
36+ CUSTOM_CRT = 2 ,
37+ } tls_mode ;
38+
2639static const int STRATUM_ID_CONFIGURE = 1 ;
2740static const int STRATUM_ID_SUBSCRIBE = 2 ;
2841
@@ -35,23 +48,22 @@ typedef struct
3548 uint8_t * merkle_branches ;
3649 size_t n_merkle_branches ;
3750 uint32_t version ;
38- uint32_t version_mask ;
3951 uint32_t target ;
4052 uint32_t ntime ;
4153 uint32_t difficulty ;
54+ bool clean_jobs ;
4255} mining_notify ;
4356
4457typedef struct
4558{
4659 char * extranonce_str ;
4760 int extranonce_2_len ;
4861
49- int64_t message_id ;
62+ int message_id ;
5063 // Indicates the type of request the message represents.
5164 stratum_method method ;
5265
5366 // mining.notify
54- int should_abandon_work ;
5567 mining_notify * mining_notification ;
5668 // mining.set_difficulty
5769 uint32_t new_difficulty ;
@@ -62,24 +74,37 @@ typedef struct
6274 char * error_str ;
6375} StratumApiV1Message ;
6476
77+ typedef struct {
78+ int64_t timestamp_us ;
79+ bool tracking ;
80+ } RequestTiming ;
81+
82+ esp_transport_handle_t STRATUM_V1_transport_init (tls_mode tls , char * cert );
83+
6584void STRATUM_V1_initialize_buffer ();
6685
67- char * STRATUM_V1_receive_jsonrpc_line (int sockfd );
86+ char * STRATUM_V1_receive_jsonrpc_line (esp_transport_handle_t transport );
6887
69- int STRATUM_V1_subscribe (int socket , int send_uid , char * model );
88+ int STRATUM_V1_subscribe (esp_transport_handle_t transport , int send_uid , const char * model );
7089
7190void STRATUM_V1_parse (StratumApiV1Message * message , const char * stratum_json );
7291
7392void STRATUM_V1_free_mining_notify (mining_notify * params );
7493
75- int STRATUM_V1_authenticate (int socket , int send_uid , const char * username , const char * pass );
94+ int STRATUM_V1_authorize (esp_transport_handle_t transport , int send_uid , const char * username , const char * pass );
95+
96+ int STRATUM_V1_configure_version_rolling (esp_transport_handle_t transport , int send_uid , uint32_t * version_mask );
7697
77- int STRATUM_V1_configure_version_rolling ( int socket , int send_uid , uint32_t * version_mask );
98+ int STRATUM_V1_pong ( esp_transport_handle_t transport , int message_id );
7899
79- int STRATUM_V1_suggest_difficulty (int socket , int send_uid , uint32_t difficulty );
100+ int STRATUM_V1_suggest_difficulty (esp_transport_handle_t transport , int send_uid , uint32_t difficulty );
80101
81- int STRATUM_V1_submit_share (int socket , int send_uid , const char * username , const char * jobid ,
102+ int STRATUM_V1_extranonce_subscribe (esp_transport_handle_t transport , int send_uid );
103+
104+ int STRATUM_V1_submit_share (esp_transport_handle_t transport , int send_uid , const char * username , const char * job_id ,
82105 const char * extranonce_2 , const uint32_t ntime , const uint32_t nonce ,
83- const uint32_t version );
106+ const uint32_t version_bits );
107+
108+ float STRATUM_V1_get_response_time_ms (int request_id , int64_t receive_time_us );
84109
85- #endif // STRATUM_API_H
110+ #endif // STRATUM_API_H
0 commit comments