Refreshing of wallet balance is updated
@@ -88,8 +88,8 @@ struct connection_pool_data {
uint8_t data_size;
uint8_t block_size;
struct pollfd connection_descriptor;
- struct miner_pool_data *miner; // More than one connection may lead to the same miner, it is needed to track
- int balance_sent; // this behaviour to avoid potential exploit of the service.
+ struct miner_pool_data *miner;
+ xdag_amount_t balance; // allows to track and refresh wallet balance
uint32_t shares_count;
};
@@ -553,7 +553,6 @@ static void calculate_nopaid_shares(struct connection_pool_data *conn_data, stru
}
conn_data->maxdiff[i] = diff;
- conn_data->balance_sent = 0;
// share already counted, but we will update the maxdiff so the most difficult share will be counted.
} else if(diff > conn_data->maxdiff[i]) {
conn_data->maxdiff[i] = diff;
@@ -774,12 +773,15 @@ static int send_data_to_connection(connection_list_element *connection, int *pro
conn_data->shares_count = 0;
fields_count = 2;
memcpy(data, task->task, fields_count * sizeof(struct xdag_field));
- } else if(!conn_data->balance_sent && conn_data->miner && time(0) >= (conn_data->task_time << 6) + 4) {
- conn_data->balance_sent = 1;
+ } else if(conn_data->miner && time(0) >= (conn_data->task_time << 6) + 4) {
+ const xdag_amount_t actual_balance = xdag_get_balance(data[0].data);
+ if(actual_balance != conn_data->balance) {
+ conn_data->balance = actual_balance;
memcpy(data[0].data, conn_data->miner->id.data, sizeof(xdag_hash_t));
- data[0].amount = xdag_get_balance(data[0].data);
+ data[0].amount = actual_balance;
fields_count = 1;
}
+ }
if(fields_count) {
*processed = 1;
