-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from ledgerleapllc/staging
Staging to master
- Loading branch information
Showing
190 changed files
with
13,914 additions
and
1,494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Contributing to Casper Association Member Portal | ||
|
||
### Please follow these guidelines if you want to contribute to this project | ||
|
||
1. Fork the project. | ||
2. Create a new branch from master (e.g. features/my-new-feature or issue/123-my-bugfix) | ||
3. Try to follow the same coding style with regards to spacing and line width, etc. Following PSR-4 will more than suffice. | ||
4. Create a pull request. Please create PR to development branch so we can do proper testing and staging before merging with master branch. | ||
|
||
### Report bugs using Github issues | ||
|
||
You can report a bug by clicking on the issues tab and 'New Issue'. Describe the issue the best you can. This makes it easy to fork and create a branch named after the issue purposed for fixing it. | ||
|
||
Thank you for your interest in the project! | ||
|
||
For security related issues, please email [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Ballot; | ||
use Carbon\Carbon; | ||
use Illuminate\Console\Command; | ||
|
||
class CheckBallot extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'ballot:check'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'ballot check'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
$settings = getSettings(); | ||
$quorumRate = $settings['quorum_rate_ballot'] ?? 50; | ||
$now = Carbon::now('UTC'); | ||
$ballots = Ballot::with(['vote'])->where('status', 'active')->where('time_end', '<=', $now)->get(); | ||
foreach ($ballots as $ballot) { | ||
$vote = $ballot->vote; | ||
if ($vote->result_count == 0) { | ||
$ballot->status = 'fail'; | ||
$ballot->save(); | ||
} else { | ||
$quorum = $vote->for_value / $vote->result_count * 100; | ||
if($quorum >= $quorumRate) { | ||
$ballot->status = 'pass'; | ||
} else { | ||
$ballot->status = 'fail'; | ||
} | ||
$ballot->save(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\MonitoringCriteria; | ||
use App\Models\User; | ||
|
||
use Carbon\Carbon; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class CheckNodeStatus extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'node-status:check'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Check node status'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
$uptime = MonitoringCriteria::where('type', 'uptime')->first(); | ||
$uptimeProbationStart = $uptime->probation_start; | ||
if ($uptime->given_to_correct_unit == 'Weeks') { | ||
$uptimeTime = (float) $uptime->given_to_correct_value * 7 * 24; | ||
} else if ($uptime->given_to_correct_unit == 'Days') { | ||
$uptimeTime = (float) $uptime->given_to_correct_value * 24; | ||
} else { | ||
$uptimeTime = (float) $uptime->given_to_correct_value; | ||
} | ||
|
||
$blockHeight = MonitoringCriteria::where('type', 'block-height')->first(); | ||
$blockHeightProbationStart = (float) $blockHeight->probation_start; | ||
if ($blockHeight->given_to_correct_unit == 'Weeks') { | ||
$blockHeightTime = (float) $blockHeight->given_to_correct_value * 7 * 24; | ||
} else if ($blockHeight->given_to_correct_unit == 'Days') { | ||
$blockHeightTime = (float) $blockHeight->given_to_correct_value * 24; | ||
} else { | ||
$blockHeightTime = (float) $blockHeight->given_to_correct_value; | ||
} | ||
|
||
$updateResponsiveness = MonitoringCriteria::where('type', 'update-responsiveness')->first(); | ||
$updateResponsivenessProbationStart = (float) $updateResponsiveness->probation_start; | ||
if ($updateResponsiveness->given_to_correct_unit == 'Weeks') { | ||
$updateResponsivenessTime = (float)$updateResponsiveness->given_to_correct_value * 7 * 24; | ||
} else if ($updateResponsiveness->given_to_correct_unit == 'Days') { | ||
$updateResponsivenessTime = (float) $updateResponsiveness->given_to_correct_value * 24; | ||
} else { | ||
$updateResponsivenessTime = (float) $updateResponsiveness->given_to_correct_value; | ||
} | ||
|
||
$now = Carbon::now('UTC'); | ||
$users = User::where('role', 'member') | ||
->where('banned', 0) | ||
->with(['metric', 'nodeInfo', 'profile']) | ||
->get(); | ||
|
||
foreach ($users as $user) { | ||
$user->node_status = 'Online'; | ||
$user->save(); | ||
|
||
$nodeInfo = $user->nodeInfo ? $user->nodeInfo : $user->metric; | ||
|
||
if (!$nodeInfo || !$user->node_verified_at || !$user->letter_verified_at || !$user->signature_request_id) { | ||
$user->node_status = null; | ||
$user->save(); | ||
} else if ($user->is_fail_node == 1) { | ||
$user->node_status = 'Offline'; | ||
$user->save(); | ||
} else if ($nodeInfo) { | ||
$nodeInfo->uptime = $nodeInfo->uptime ? $nodeInfo->uptime : 0; | ||
$nodeInfo->block_height_average = $nodeInfo->block_height_average ? $nodeInfo->block_height_average : 0; | ||
$nodeInfo->update_responsiveness = $nodeInfo->update_responsiveness ? $nodeInfo->update_responsiveness : 100; | ||
if ( | ||
$nodeInfo->uptime >= $uptimeProbationStart && | ||
$nodeInfo->block_height_average >= $blockHeightProbationStart && | ||
$nodeInfo->update_responsiveness >= $updateResponsivenessProbationStart | ||
) { | ||
$user->node_status = 'Online'; | ||
$user->save(); | ||
|
||
$nodeInfo->uptime_time_start = null; | ||
$nodeInfo->uptime_time_end = null; | ||
|
||
$nodeInfo->block_height_average_time_start = null; | ||
$nodeInfo->block_height_average_time_end = null; | ||
|
||
$nodeInfo->update_responsiveness_time_start = null; | ||
$nodeInfo->update_responsiveness_time_end = null; | ||
|
||
$nodeInfo->save(); | ||
} | ||
} | ||
|
||
if ($user->profile && $user->profile->status == 'approved' && $nodeInfo) { | ||
$user->profile->extra_status = null; | ||
$user->profile->save(); | ||
|
||
if ($nodeInfo->uptime < $uptimeProbationStart) { | ||
$user->profile->extra_status = 'On Probation'; | ||
$nodeInfo->uptime_time_start = now(); | ||
$nodeInfo->uptime_time_end = Carbon::now('UTC')->addHours($uptimeTime); | ||
} | ||
|
||
if ($nodeInfo->block_height_average < $blockHeightProbationStart) { | ||
$user->profile->extra_status = 'On Probation'; | ||
$nodeInfo->block_height_average_time_start = now(); | ||
$nodeInfo->block_height_average_time_end = Carbon::now('UTC')->addHours($blockHeightTime); | ||
} | ||
|
||
if ($nodeInfo->update_responsiveness < $updateResponsivenessProbationStart) { | ||
$user->profile->extra_status = 'On Probation'; | ||
$nodeInfo->update_responsiveness_time_start = now(); | ||
$nodeInfo->update_responsiveness_time_end = Carbon::now('UTC')->addHours($updateResponsivenessTime); | ||
} | ||
|
||
$user->profile->save(); | ||
$nodeInfo->save(); | ||
|
||
if ($user->profile->extra_status == 'On Probation') { | ||
if ($nodeInfo->uptime_time_end <= $now && $nodeInfo->uptime < $uptimeProbationStart) { | ||
$user->profile->extra_status = 'Suspended'; | ||
} | ||
if ($nodeInfo->block_height_average_time_end <= $now && $nodeInfo->block_height_average < $blockHeightProbationStart) { | ||
$user->profile->extra_status = 'Suspended'; | ||
} | ||
if ($nodeInfo->update_responsiveness_time_end <= $now && $nodeInfo->update_responsiveness < $updateResponsivenessProbationStart) { | ||
$user->profile->extra_status = 'Suspended'; | ||
} | ||
$user->profile->save(); | ||
} | ||
} | ||
|
||
/* | ||
if ($user->node_status != 'Probation' && $user->node_status != 'Pulled') { | ||
if ($nodeInfo->uptime < $uptimeProbationStart) { | ||
$user->node_status = 'Probation'; | ||
$nodeInfo->uptime_time_start = now(); | ||
$nodeInfo->uptime_time_end = Carbon::now('UTC')->addHours($uptimeTime); | ||
} | ||
if ($nodeInfo->block_height_average < $blockHeightProbationStart) { | ||
$user->node_status = 'Probation'; | ||
$nodeInfo->block_height_average_time_start = now(); | ||
$nodeInfo->block_height_average_time_end = Carbon::now('UTC')->addHours($blockHeightTime); | ||
} | ||
if ($nodeInfo->update_responsiveness < $updateResponsivenessProbationStart) { | ||
$user->node_status = 'Probation'; | ||
$nodeInfo->update_responsiveness_time_start = now(); | ||
$nodeInfo->update_responsiveness_time_end = Carbon::now('UTC')->addHours($updateResponsivenessTime); | ||
} | ||
$user->save(); | ||
$nodeInfo->save(); | ||
continue; | ||
} | ||
if ($user->node_status == 'Probation') { | ||
if ($nodeInfo->uptime_time_end <= $now && $nodeInfo->uptime < $uptimeProbationStart) { | ||
$user->node_status = 'Pulled'; | ||
} | ||
if ($nodeInfo->block_height_average_time_end <= $now && $nodeInfo->block_height_average < $blockHeightProbationStart) { | ||
$user->node_status = 'Pulled'; | ||
} | ||
if ($nodeInfo->update_responsiveness_time_end <= $now && $nodeInfo->update_responsiveness < $updateResponsivenessProbationStart) { | ||
$user->node_status = 'Pulled'; | ||
} | ||
$user->save(); | ||
} | ||
*/ | ||
} | ||
} | ||
} |
Oops, something went wrong.