some kind of blockchain is been created
This commit is contained in:
1
examples/first/asdasd.js
Symbolic link
1
examples/first/asdasd.js
Symbolic link
@@ -0,0 +1 @@
|
||||
asdasd.js
|
38
examples/first/example.js
Normal file
38
examples/first/example.js
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
// Initializin of the variable for instance of asdasd
|
||||
let blockchain;
|
||||
|
||||
function init_asdasd(asdasd) {
|
||||
if (indexedDB instanceof IDBFactory) {
|
||||
// Supports indexedDB
|
||||
|
||||
// Initializing of asdasd
|
||||
blockchain = new asdasd(
|
||||
"test",
|
||||
(text, settings, previous, created) => {
|
||||
let hash = "";
|
||||
let nonce = 0;
|
||||
|
||||
do {
|
||||
hash = nobleHashes.utils.bytesToHex(nobleHashes.blake3(
|
||||
previous + text + created + ++nonce,
|
||||
settings,
|
||||
));
|
||||
} while (hash.substring(0, 3) !== "000");
|
||||
|
||||
return { nonce, hash };
|
||||
},
|
||||
);
|
||||
} else {
|
||||
// Not supports indexed
|
||||
|
||||
// Show the error
|
||||
document.getElementsByTagName("main")[0].innerText =
|
||||
"Your browser does not support indexedDB which is used for asdasd blockchain";
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof window.asdasd === "function") (() => init_asdasd(asdasd))();
|
||||
else {document.addEventListener("asdasd.initialized", (e) =>
|
||||
init_asdasd(e.asdasd));}
|
17
examples/first/index.html
Normal file
17
examples/first/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Example</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>see "example.js"</p>
|
||||
<script src="noble-hashes.js" defer></script>
|
||||
<script src="asdasd.js" defer></script>
|
||||
<script src="example.js" defer></script>
|
||||
</body>
|
||||
|
||||
</html>
|
1
examples/first/noble-hashes.js
Symbolic link
1
examples/first/noble-hashes.js
Symbolic link
@@ -0,0 +1 @@
|
||||
noble-hashes.js
|
Reference in New Issue
Block a user