Browse Source

SSM: Propagate proxy-share difficulty changes to established connections

Luke Dashjr 11 years ago
parent
commit
2449965927
3 changed files with 35 additions and 0 deletions
  1. 4 0
      driver-proxy.c
  2. 4 0
      driver-proxy.h
  3. 27 0
      driver-stratum.c

+ 4 - 0
driver-proxy.c

@@ -143,6 +143,10 @@ const char *proxy_set_diff(struct cgpu_info * const proc, const char * const opt
 	
 	
 	client->desired_share_pdiff = nv;
 	client->desired_share_pdiff = nv;
 	
 	
+#ifdef USE_LIBEVENT
+	stratumsrv_client_changed_diff(client);
+#endif
+	
 	return NULL;
 	return NULL;
 }
 }
 
 

+ 4 - 0
driver-proxy.h

@@ -27,4 +27,8 @@ struct proxy_client {
 
 
 extern struct proxy_client *proxy_find_or_create_client(const char *user);
 extern struct proxy_client *proxy_find_or_create_client(const char *user);
 
 
+#ifdef USE_LIBEVENT
+extern void stratumsrv_client_changed_diff(struct proxy_client *);
+#endif
+
 #endif
 #endif

+ 27 - 0
driver-stratum.c

@@ -178,6 +178,33 @@ bool stratumsrv_update_notify_str(struct pool * const pool, bool clean)
 	return true;
 	return true;
 }
 }
 
 
+void stratumsrv_client_changed_diff(struct proxy_client * const client)
+{
+	int connections_affected = 0, connections_changed = 0;
+	struct stratumsrv_conn_userlist *ule, *ule2;
+	LL_FOREACH(client->stratumsrv_connlist, ule)
+	{
+		struct stratumsrv_conn * const conn = ule->conn;
+		
+		++connections_affected;
+		
+		float desired_share_pdiff = client->desired_share_pdiff;
+		LL_FOREACH(conn->authorised_users, ule2)
+		{
+			struct proxy_client * const other_client = ule2->client;
+			if (other_client->desired_share_pdiff < desired_share_pdiff)
+				desired_share_pdiff = other_client->desired_share_pdiff;
+		}
+		if (conn->desired_share_pdiff != desired_share_pdiff)
+		{
+			conn->desired_share_pdiff = desired_share_pdiff;
+			++connections_changed;
+		}
+	}
+	if (connections_affected)
+		applog(LOG_DEBUG, "Proxy-share difficulty change for user '%s' affected %d connections (%d changed difficulty)", client->username, connections_affected, connections_changed);
+}
+
 static
 static
 void _ssj_free(struct stratumsrv_job * const ssj)
 void _ssj_free(struct stratumsrv_job * const ssj)
 {
 {