some kind of blockchain is been created

This commit is contained in:
2024-01-14 06:56:01 +07:00
parent b279e416a3
commit c18318f5de
7 changed files with 3009 additions and 2 deletions

1
examples/first/asdasd.js Symbolic link
View File

@@ -0,0 +1 @@
asdasd.js

38
examples/first/example.js Normal file
View 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
View 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>

View File

@@ -0,0 +1 @@
noble-hashes.js