-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🌍[Spring] Mining difficulty full-stack
- Loading branch information
Showing
6 changed files
with
103 additions
and
4 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
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
27 changes: 27 additions & 0 deletions
27
src/backend/blockchainIOT/src/main/resources/static/js/blockParams.js
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,27 @@ | ||
/* | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Other/javascript.js to edit this template | ||
*/ | ||
|
||
$(document).ready( function () { | ||
//Set difficulty on page load | ||
$.getJSON("api/fog/block/mine/difficulty", function(data) { | ||
$('#difficultyRange').val(data); | ||
$('#difficultyValue').html(data); | ||
}); | ||
|
||
//Change difficulty on request | ||
$('#difficultyRange').change(function(){ | ||
//Perform mining request to endpoint, using input data | ||
$.post( "api/fog/block/mine/difficulty", { difficulty: $('#difficultyRange').val() }, function( data ) { | ||
if(data === true){ | ||
$('#difficultyRange').val(data); | ||
$('#difficultyValue').html(data); | ||
} | ||
}); | ||
|
||
}); | ||
}); | ||
|
||
|
||
|
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 |
---|---|---|
|
@@ -59,18 +59,41 @@ | |
<!-- Begin page content --> | ||
<main class="flex-shrink-0"> | ||
<div class="container"> | ||
<h1 class="mt-5">Adopting the IoT to Blockchain!</h1> | ||
<p class="lead">The aim of this project is to create a blockchain solution to solve the maintainability, security, and privacy issues with IOT devices.</p> | ||
<h1 class="mt-5">Settings</h1> | ||
<div class="alert alert-warning" role="alert"> | ||
<h4 class="alert-heading">Warning!</h4> | ||
<p>Changing the difficulty level of the mining process, will increase the amount of time it takes for a block to get mined.</p> | ||
<hr> | ||
<p class="mb-0">In addition, the blockchain stored on the ledger will be <b>permanently removed</b> as this will be invalid after!</p> | ||
</div> | ||
<p class="lead">The following parameters can be customised</p> | ||
<div> | ||
<form> | ||
<div class="form-group col-lg"> | ||
<label>Mining difficulty</label> | ||
<p>This is the number matching leading zero's to be matched when hashing in the mining process.</p> | ||
<input type="range" class="form-range" min="1" max="10" step="1" id="difficultyRange" onInput="$('#difficultyValue').html($(this).val())"> | ||
<span id="difficultyValue">5<!-- Default value --></span> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</main> | ||
|
||
<footer class="footer fixed-bottom mt-auto py-3 bg-light"> | ||
<div class="container"> | ||
<span class="text-muted">ChainIOT; Adopting the IoT to Blockchain | ||
</br>Henri Koci - Brunel University London</span> | ||
</div> | ||
</footer> | ||
|
||
<!-- JQuery 3.6.0 CDN Script --> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
|
||
<!-- Option 1: Bootstrap Bundle with Popper --> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> | ||
|
||
<!-- Load cards on document launch --> | ||
<script src="js/blockParams.js"></script> | ||
</body> | ||
</html> |