Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bdr-pro/blockchain
Do good, feel good. Share your computing power and help the science squad level up. ๐ง ๐ฌ while staying ghost online. ๐ต๏ธโโ๏ธ
https://github.com/bdr-pro/blockchain
artificial-intelligence blockchain blockchain-technology cryptocurrency privacy
Last synced: about 2 months ago
JSON representation
Do good, feel good. Share your computing power and help the science squad level up. ๐ง ๐ฌ while staying ghost online. ๐ต๏ธโโ๏ธ
- Host: GitHub
- URL: https://github.com/bdr-pro/blockchain
- Owner: BDR-Pro
- Created: 2024-02-28T21:01:24.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-03-29T16:52:09.000Z (10 months ago)
- Last Synced: 2024-03-30T16:26:49.601Z (9 months ago)
- Topics: artificial-intelligence, blockchain, blockchain-technology, cryptocurrency, privacy
- Language: Rust
- Homepage:
- Size: 730 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ Alpha Centauri Blockchain: Next-Gen Privacy is Here! ๐
## Table of Contents
- [๐ Alpha Centauri Blockchain: Next-Gen Privacy is Here! ๐](#-alpha-centauri-blockchain-next-gen-privacy-is-here-)
- [Table of Contents](#table-of-contents)
- [Getting Your Feet Wet ๐](#getting-your-feet-wet-)
- [Setup Real Quick](#setup-real-quick)
- [Let's Roll ๐ฒ](#lets-roll-)
- [What's this? ๐ฑ](#whats-this-)
- [Proof of Computing](#proof-of-computing)
- [Keep it on the DL](#keep-it-on-the-dl)
- [Cash Rules](#cash-rules)
- [Sneak Peek Code ๐ต๏ธโโ๏ธ](#sneak-peek-code-๏ธ๏ธ)
- [Dive Deeper ๐คฟ](#dive-deeper-)
- [๐ฅ Reward System๐](#-reward-system)
- [Yo, What's Up With The 1 Block Reward? ๐ค๐ธ](#yo-whats-up-with-the-1-block-reward-)
- [Time Travel But For Crypto ๐๐](#time-travel-but-for-crypto-)
- [Treasure Hunt: Total Circulation ๐ดโโ ๏ธ๐ฐ](#treasure-hunt-total-circulation-๏ธ)
- [Wrap It Up, Will Ya? ๐](#wrap-it-up-will-ya-)
- [Holla at Us ๐ข](#holla-at-us-)
- [๐ How The Trustless System works! ๐](#-how-the-trustless-system-works-)
- [Yo, Future Blockchain Moguls! ๐พ](#yo-future-blockchain-moguls-)
- [๐ The Ultimate To-Do List](#-the-ultimate-to-do-list)
- [1. **Give Back to Get Ahead** ๐๏ธ](#1-give-back-to-get-ahead-๏ธ)
- [2. **Set Up Your Secret Lair** ๐ง ](#2-set-up-your-secret-lair-)
- [3. **Link Up and Lock Down** ๐๐](#3-link-up-and-lock-down-)
- [4. **Receive the Digits** ๐ฐ](#4-receive-the-digits-)
- [5. **Make It Rain (New Funds, Who Dis?)** ๐ณ](#5-make-it-rain-new-funds-who-dis-)
- [6. **Seal the Deal** โ ](#6-seal-the-deal-)
- [๐ Conclusion](#-conclusion)
- [๐ Proof of Computing: Get Rewarded for Flexing Your AI Muscles! ๐ช๐ค](#-proof-of-computing-get-rewarded-for-flexing-your-ai-muscles-)
- [๐ง Train \& Gain](#-train--gain)
- [๐ Learning = Earning](#-learning--earning)
- [๐ How It Works](#-how-it-works)
- [๐ The Real MVPs](#-the-real-mvps)
- [How to Calculate TeraFLOPs Like a Gen Z Pro ๐โจ](#how-to-calculate-teraflops-like-a-gen-z-pro-)
- [What's a TeraFLOP, You Ask? ๐ค๐ฅ](#whats-a-teraflop-you-ask-)
- [Getting the Deets (Details, obvi) ๐๐](#getting-the-deets-details-obvi-)
- [Step 1: Warm-Up ๐โโ๏ธ๐ฅ](#step-1-warm-up-๏ธ)
- [Step 2: The Magic Spell ๐งโโ๏ธโจ](#step-2-the-magic-spell-๏ธ)
- [Step 3: Flex ๐ช๐](#step-3-flex-)
- [Example Output](#example-output)
- [Pro Tips for True Techies ๐๐](#pro-tips-for-true-techies-)
- [Conclusion: You're Now a TeraFLOP Titan ๐โจ](#conclusion-youre-now-a-teraflop-titan-)
- [๐ Train Your Models Like a Boss! ๐๐ฅ](#-train-your-models-like-a-boss-)
- [๐ Unleash The Power of Your Data](#-unleash-the-power-of-your-data)
- [๐ค What's the Deal?](#-whats-the-deal)
- [๐ป Features That Will Make You Go "Woah!"](#-features-that-will-make-you-go-woah)
- [๐ How to Get Started](#-how-to-get-started)
- [Directories](#directories)
- [๐ Installation Guide (The Gen Z Way)](#-installation-guide-the-gen-z-way)
- [1. Getting OpenSSL (The Gatekeeper)](#1-getting-openssl-the-gatekeeper)
- [2. Let's Get Rusty](#2-lets-get-rusty)
- [3. Build and Run](#3-build-and-run)
- [4. install the required packages](#4-install-the-required-packages)
- [5. OpenSSL Dance](#5-openssl-dance)
- [๐ Boom! You're Now a Rustacean-Crypto-Wizard!๐ง๐ผโโ๏ธ๐ฎ๐ฉ๐ชโจ](#-boom-youre-now-a-rustacean-crypto-wizard๏ธ)
- [Big Update #1](#big-update-1)
- [Update **2**](#update-2)
- ["WebSquad connects nodes using WebSocket. Ping yourself, check Tor status, and sync with peers listed in 'dns.txt'. Dive into decentralized networking! #WebSquad"](#websquad-connects-nodes-using-websocket-ping-yourself-check-tor-status-and-sync-with-peers-listed-in-dnstxt-dive-into-decentralized-networking-websquad)
- ["Connect and vibe with your digital tribe! ๐ Our 'WebSquad' platform pings via WS, linking you to other cool WS clients. Stay synced, stay connected. #WebSquad #StayLinked"](#connect-and-vibe-with-your-digital-tribe--our-websquad-platform-pings-via-ws-linking-you-to-other-cool-ws-clients-stay-synced-stay-connected-websquad-staylinked)
- [๐ Holla at Us](#-holla-at-us)Yo, whatโs up, fam? Welcome to the dopest blockchain on the block - **Alpha Centauri**. ๐ Forget all that old-school balance and address nonsense. Weโre here to flip the script with our unique **banknotes vibe** - think exclusive signed rewards you can flex with your private key. ๐๏ธ๐ฐ
## Getting Your Feet Wet ๐
No Rust? No problem! Slide over to [Rust's crib](https://www.rust-lang.org/learn/get-started) to get set up. This isn't just a blockchain; it's your ticket to helping the AI fam while staying ghost online. ๐ต๏ธโโ๏ธ
### Setup Real Quick
Grab the goods with:
```bash
git clone https://github.com/BDR-Pro/blockchain.git
cd blockchain
```Make sure your `Cargo.toml` is popping with:
```toml
chrono = "0.4"
serde = { version = "1.0", features = ["derive"] }
sha2 = "0.10"
openssl = "0.10"
serde_json = "1.0"
```#### Let's Roll ๐ฒ
Jump into your project space and kick it off with:
```bash
cargo run
```## What's this? ๐ฑ
### Proof of Computing
Do good, feel good. Share your computing power and help the science squad level up. ๐ง ๐ฌ
### Keep it on the DL
Connect with the crew through Tor. It's all about that stealth mode. Check the [Tor Traffic Router](https://crates.io/crates/Tor_Traffic_Router) to get the lowdown.
### Cash Rules
- **Big Baller**: Alpha Centauri
- **Pocket Change**: Tensor (1 millionth of a boss Alpha Centauri)## Sneak Peek Code ๐ต๏ธโโ๏ธ
Check this:
```rust
// Essential imports and the blueprint...fn sign(message: &String) -> Vec {
// Secret handshake logic...
}#[derive(Debug, Serialize, Deserialize)]
struct Block {
// The building blocks...
}impl Block {
fn new(data: String, previous_hash: String, block_number:u64 , reward:u64) -> Result {
// Crafting the block...
}
}// Dive deeper into the matrix...
```### Dive Deeper ๐คฟ
Get nosy. Break it down. Remix it. This is your playground.
## ๐ฅ Reward System๐
## Yo, What's Up With The 1 Block Reward? ๐ค๐ธ
Alright, alright, alright, let's break it down real simple. You know how in the crypto world things keep halving until they're like, super tiny? We crunched some hardcore numbers and guess what? ๐ง
After vibing through exactly **655,360 blocks**, our rewards are hitting that sweet, sweet spot of just **1 per block**. Yeah, you heard that right! But like, don't rush; this ain't happening overnight. We're talking a chill journey of about **12.47 years**. Set your calendars, folks! ๐ โณ
## Time Travel But For Crypto ๐๐
We're not just dropping numbers for the fun of it. Imagine this: every block's a 10-minute mini-party, and after 655,360 of those, bam, we land at the 1 reward station. But here's the kicker โ it's gonna take us around **12.47 years**. Yeah, that's a lot of TikToks you could scroll through. ๐ฑ๐
## Treasure Hunt: Total Circulation ๐ดโโ ๏ธ๐ฐ
Now, let's talk the big bucks, the total moolah in circulation by the time we hit the 1 per block paradise. We're looking at a whopping **102,710,272** in the vault! That's right, start dreaming of all the avocados and lattes that could buy. ๐ฅโ
## Wrap It Up, Will Ya? ๐
So there you have it, folks! Kick back, relax, and let the blocks roll because we're in for a long ride to 1-ville. Remember, in the crypto game, patience is more than just a virtue; it's the way to the treasure. ๐๐
Stay tuned, stay hyped, and keep those blocks stacking! ๐๐ฅ
## Holla at Us ๐ข
Got fire ideas? Weโre all ears. Hit us up with an issue or slide into our DMs with a pull request. Letโs skyrocket Alpha Centauri to the moon! ๐๐
## ๐ How The Trustless System works! ๐
### Yo, Future Blockchain Moguls! ๐พ
Wanna dive into the wild world of crypto donations, onion servers, and making bank (securely)? Buckle up, 'cause we're spilling the tea on how to get your digital wallets thicc while supporting science. Let's get this bread, but like, responsibly. ๐๐ธ
### ๐ The Ultimate To-Do List
#### 1. **Give Back to Get Ahead** ๐๏ธ
- Wanna train your model? Cool, but let's not forget the little guys. Pledge **10% of today's reward** to the science research labs on the blockchain. It's like tipping your barista, but for brainiacs.
- The donation percentage, such as **10%**, varies based on the **teraFLOPs** required for successful mining operations.
- Check out the list of eligible labs and make your donation. Remember, karma's a boomerang โ what goes around, comes around!#### 2. **Set Up Your Secret Lair** ๐ง
- Time to go underground. Set up your `.onion` server. Yeah, it's not just for secret recipes; it's your portal to the crypto underworld.
- Not sure how? Look up "Setting up an onion server" and follow the steps. It's like following a recipe, but instead of a cake, you get a secure server.#### 3. **Link Up and Lock Down** ๐๐
- Got your `.onion` link? Sweet. Share it with your peeps who wanna send you funds. But remember, with great power comes great responsibility.
- Keep it on the down-low. Only share with trusted contacts. We're building a trust tree here, folks.#### 4. **Receive the Digits** ๐ฐ
- Once your buddy sends over their banknote serial number (aka their funds' private key), you're ready to roll.
- This number is like the secret handshake. Treat it with respect.#### 5. **Make It Rain (New Funds, Who Dis?)** ๐ณ
- Time to generate a new pair of ECDSA (Elliptic Curve Digital Signature Algorithm) keys. It's like getting a brand-new identity, but for your wallet.
- Sign a new message declaring the fund transfer from the old banknote to your shiny new one. It's like renewing your vows, but with money.#### 6. **Seal the Deal** โ
- Finalize the transaction. Confirm the amount transferred matches the old banknote. No bamboozles allowed.
- Once verified, consider your purchase donezo. Congratulations, you've officially entered the crypto cool kids club.### ๐ Conclusion
Welcome to the future, where your transactions are as secure as your DMs should be. Remember, this isn't just about making money; it's about building a community, supporting science, and staying secure. So, let's get to work, but also let's keep it fun. Stay safe, stay savvy, and let's disrupt the digital world one transaction at a time. ๐๐ฅ
## ๐ Proof of Computing: Get Rewarded for Flexing Your AI Muscles! ๐ช๐ค
Yo, fam! Welcome to the future where your brainpower boosts your bank balance. Welcome to the lit side of tech โ **Proof of Computing**. Itโs not just about mining; itโs about shining. ๐โจ
### ๐ง Train & Gain
Forget hitting the gym; let's get those neural networks pumping! Hereโs the deal:
- **Train a Model, Stack that Coin**: Dive into our platform, pick a model, and start training. Your computer does the heavy lifting, and you? You just chill and watch the rewards roll in. ๐๏ธโโ๏ธ๐ฐ
- **Eco-Friendly Flex**: Sick of blockchain baddies wrecking the planet? Us too. Proof of Computing is all about that green energy, baby. Train models, save the world, get paid. Captain Planet would be proud. ๐โค๏ธ
### ๐ Learning = Earning
- **All the Cool Kids Are Doing It**: Jump on board with AI enthusiasts, data scientists, and the curious cats of Gen Z. Whether youโre a seasoned pro or just AI-curious, thereโs room for everyone.
- **Expand Your Mind and Wallet**: Every model you train helps solve real-world problems, from cracking climate change to revolutionizing medicine. And yeah, you get rewarded for it. Knowledge is power, and now, itโs also profit. ๐โก๏ธ๐ธ
### ๐ How It Works
1. **Donwload the .exe**: Grab your digital gear and download our Proof of Computing .exe. Itโs like getting a backstage pass to the AI world.
2. **Select Your Mission**: Choose which AI model you wanna help train. From detecting cute cats online to predicting the next big TikTok trend, weโve got it all.
3. **Let the Games Begin**: Set your computer to work. Go binge-watch your fave series, and let your PC do its thing.
4. **Rewards Galore**: Done training? BOOM! Rewards land straight into your account. Itโs like finding money in your other jeans, but way cooler.
### ๐ The Real MVPs
At the end of the day, itโs not just about making bank. Itโs about making a difference. By contributing your computing power, you're part of something bigger โ a community of do-gooders, dreamers, and data crunchers making the digital world a better place.
So, what are you waiting for? Join us, get smart, get paid, and letโs make the internet awesome together. ๐๐พ
## How to Calculate TeraFLOPs Like a Gen Z Pro ๐โจ
Hey fam! Welcome to the ultra-cool, super chill guide on calculating those big brain numbers we call TeraFLOPs. If you're diving into the deep end of AI models or just wanna flex on your tech squad, you've come to the right place. Let's decode this like we're breaking into the mainframe of the future. ๐๐ป
## What's a TeraFLOP, You Ask? ๐ค๐ฅ
A TeraFLOP (that's 'floating-point operations per second', if you wanna get all dictionary about it) is like the horsepower of your AI ride. It tells you how many trillions of math problems your computer or model can solve every second. More TeraFLOPs? More power to you โ literally. We're talking mega mind speeds, people!
## Getting the Deets (Details, obvi) ๐๐
Before you start, you'll need:
- Your model (this ain't no fashion show โ we're talking neural networks, baby!)
- Some tools (TensorFlow, PyTorch, or whatever floats your computational boat)
- A vibe for adventure (mandatory, no exceptions)### Step 1: Warm-Up ๐โโ๏ธ๐ฅ
Get your model up and running. Make sure it's trained, loaded, and ready to show off its smarts. We're about to put it to the test!
### Step 2: The Magic Spell ๐งโโ๏ธโจ
If you're using a tool like TensorFlow or something similar, there's usually a way to calculate those FLOPs. It might involve some code โ don't panic! Copy-paste is your friend, and so is Google.
If youโre all about that Python life (and who isnโt?), hereโs a little something you might use:
```python
# Python wizardry here
import tensorflow as tf
from tensorflow.python.profiler.model_analyzer import profile
from tensorflow.python.profiler.option_builder import ProfileOptionBuilderdef estimate_model_teraflops(model):
forward_pass = tf.function(model.call, input_signature=[tf.TensorSpec(shape=(1,) + model.input_shape[1:])])
graph_info = profile(forward_pass.get_concrete_function().graph, options=ProfileOptionBuilder.float_operation())
flops = graph_info.total_float_ops
return flops / 10**12print(f"Your model is flexing with {estimate_model_teraflops(model)} TeraFLOPs!")
```### Step 3: Flex ๐ช๐
Got that number? That's how powerful your AI model is. Share it with friends, make your enemies jealous, and maybe even impress your cat with your big brain energy.
#### Example Output
```bash
Epoch 1/5
1875/1875 โโโโโโโโโโโโโโโโโโโโ 5s 2ms/step - accuracy: 0.8798 - loss: 0.4296
Epoch 2/5
1875/1875 โโโโโโโโโโโโโโโโโโโโ 3s 1ms/step - accuracy: 0.9657 - loss: 0.1165
Epoch 3/5
1875/1875 โโโโโโโโโโโโโโโโโโโโ 3s 1ms/step - accuracy: 0.9788 - loss: 0.0744
Epoch 4/5
1875/1875 โโโโโโโโโโโโโโโโโโโโ 4s 2ms/step - accuracy: 0.9839 - loss: 0.0540
Epoch 5/5
1875/1875 โโโโโโโโโโโโโโโโโโโโ 3s 1ms/step - accuracy: 0.9875 - loss: 0.0426
313/313 โโโโโโโโโโโโโโโโโโโโ 0s 940us/step - accuracy: 0.9743 - loss: 0.0904
Loss: 0.07741480320692062, Accuracy: 0.9783999919891357
teraFLOP: 2.03452e-07
```## Pro Tips for True Techies ๐๐
- **Accuracy Over Speed**: Remember, more TeraFLOPs doesn't always mean smarter, just like more horsepower doesn't make you a better driver.
- **Stay Updated**: Tech moves fast. Keep your tools and knowledge fresh to stay on top of the game.
- **Community Is Key**: Stuck? Ask around. The internet is full of nerds (we say that lovingly) who live for this stuff.## Conclusion: You're Now a TeraFLOP Titan ๐โจ
And that's a wrap! You've just leveled up in the tech game. Use your powers for good, keep learning, and always remember: in the world of AI, today's flex is tomorrow's old news. Stay curious, stay cool, and keep calculating those TeraFLOPs! ๐๐
Peace out, digital pioneers! Keep rocking the data wave! ๐๐ฉโ๐ป๐จโ๐ป
### ๐ Train Your Models Like a Boss! ๐๐ฅ
## ๐ Unleash The Power of Your Data
Welcome to **CryptoModelTrainer**! If you're all about that crypto life and wanna train your models like a boss โ you've just found your new best friend. ๐
## ๐ค What's the Deal?
We're revolutionizing how you train your machine learning models for the crypto market. Think less hassle, more dazzle. you provide the brains (a.k.a. your Jupyter notebook), and we do the heavy lifting. It's like having your own data science squad, but cooler. ๐ก
## ๐ป Features That Will Make You Go "Woah!"
- **Jupyter Notebook Magic**: We're all about that Python life. Just drop your notebook, and we'll handle the rest. ๐
- **Data Science Vibes**: Whether you're into predicting crypto trends or analyzing market data, we've got your back. ๐
- **Slick Model Training**: Just feed us your notebook, and watch magic happen. ๐งโโ๏ธ
- **Speedy Results**: Get outputs faster than you can say "Blockchain". ๐๏ธ๐จ
- **Crystal Clear Outputs**: We keep it 100. Your results, your gains. ๐
- **Secure & Private**: Your data is your business. We keep it locked down. ๐## ๐ How to Get Started
-Ready to dive in? Here's how to get started:
- **Step 1**: Read new_task.ipynb and understand the task.
- **Step 2**: Write your code in the new_task.ipynb file.
- **Step 3**: Run the mine.rs file.
- **Step 4**: Check the output in the output.txt file.
- **Step 5**: Celebrate your model training success! ๐
- **Step 6**: Share your results with the world. You're a data hero now. ๐ฆธโโ๏ธ
- **Step 7**: Keep training, keep learning, and keep making the crypto world a better place. ๐## Directories
```bash
/blockchain
โ
โโโ my_keys
โ โโโ {timestamp}_{blocknumber}_{reward}.pem
โ
โโโ my_blocks
โ โโโ {blocknumber}.json
โ
โโโ my_flops
โ โโโ teraflops.txt
โ
โโโ my_backup
โโโ output.txt -> UUID.txt
โโโ task.py -> UUID.py
```## ๐ Installation Guide (The Gen Z Way)
We hate boring setups, so we made this as easy as ABC. But hey, before you jump in, make sure you've got OpenSSL coz we're all about that security life. ๐
### 1. Getting OpenSSL (The Gatekeeper)
- **Windows Peeps**: Grab the installer from [this link](https://slproweb.com/products/Win32OpenSSL.html). Choose the version marked 'Light' cause we like to keep it breezy. Install it and **remember the path where you put it**; you're gonna need it.
- **Mac Users**: Chill, just open your terminal and hit `brew install openssl`. Homebrew's got your back.- **Linux Gang**: You probably already have OpenSSL, but if not, `sudo apt-get install libssl-dev` (for Ubuntu) or the equivalent for your distro will sort you out.
### 2. Let's Get Rusty
Make sure you've got Rust installed. No? No worries:
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```Restart your terminal, and boom, you're in the Rust club.
### 3. Build and Run
Now, the moment of truth. Let's compile this masterpiece:
```bash
cargo build
```And then, set the stage on fire with:
```bash
cargo run
```### 4. install the required packages
```bash
pip install tensorflow
```### 5. OpenSSL Dance
If Rust starts asking where OpenSSL is at (like, "Hey, I need those secure vibes"), you tell it straight:
- **Windows**: Set `OPENSSL_DIR` environment variable to your OpenSSL path.
- **Unix-like (Mac/Linux)**: Usually chill, but if it gets fussy, export that `PKG_CONFIG_PATH` pointing to your OpenSSL lib directory.## ๐ Boom! You're Now a Rustacean-Crypto-Wizard!๐ง๐ผโโ๏ธ๐ฎ๐ฉ๐ชโจ
Congrats! You've just set up **Alpha centuri**. Dive into the code, make some noise, and build something that'll make the blockchain jealous.
## Big Update #1
>**1** add blockchain_maker as external crate
```toml
[dependencies]
blockchain_maker = 1.1.0
```>**2** add webSocket to the project
```toml
[dependencies]
websocket = "0.22.0"
```>**3** add cudaa.py to the project
as another way to calculate teraflops```python
# Define the CUDA kernel for matrix multiplication
@cuda.jit
def matmul(A, B, C):
row, col = cuda.grid(2) # Get the 2D thread indices
if row < C.shape[0] and col < C.shape[1]:
tmp = 0.0
for k in range(A.shape[1]):
tmp += A[row, k] * B[k, col]
C[row, col] = tmp```
>**4** add requirements.ipynb to the project just run it to install the required packages
```bash
python3 -m pip install -r requirements.txt
```
>**5** add ping.py to the project to check the connection between the server and the client
```python
async def test_ws():
uri = "ws://localhost:8080"
async with websockets.connect(uri) as websocket:
# Sending a "ping" message
await websocket.send("ping")
print("> ping")# Waiting for a response
response = await websocket.recv()
print(f"< {response}")```
![alt text](image.png)
## Update **2**
![alt text](dns.png)
### "WebSquad connects nodes using WebSocket. Ping yourself, check Tor status, and sync with peers listed in 'dns.txt'. Dive into decentralized networking! #WebSquad"
#### "Connect and vibe with your digital tribe! ๐ Our 'WebSquad' platform pings via WS, linking you to other cool WS clients. Stay synced, stay connected. #WebSquad #StayLinked"
1. **Start Server**: Initialize WebSocket server on port 8888.
2. **Receive Message**: Await "ping" message from connected clients.
3. **Read File**:
- Open `dns.txt`.
- Retrieve the last line (representing the latest DNS entry).
4. **Respond to Client**:
- If received message is "ping", send back the last entry.
- On error (e.g., file read error), send an error message.
5. **Loop**: Continue listening for new messages and clients.---
### ๐ Holla at Us
Got questions, suggestions, or just wanna chat about the meaning of life? Slide into our DMs. Letโs make magic happen together.
Letโs get this computational party started! ๐๐ป
### WS.rs
```rust
// Import necessary crates and modules
use futures_util::{SinkExt, StreamExt};
use rand::thread_rng;
use reqwest::Client;
use std::error::Error as StdError;
use tar::Builder;
use tokio::{
fs::File as TokioFile,
io::AsyncWriteExt,
net::{TcpListener, TcpStream},
task,
};
use tokio_socks::tcp::Socks5Stream;
use tokio_tungstenite::{accept_async, tungstenite::protocol::Message, WebSocketStream};
use url::Url;/// Downloads and synchronizes the blockchain from a random node.
///
/// This function reads a list of node addresses from a file, selects one at random,
/// and initiates a synchronization request to download the blockchain.
pub async fn download_blockchain() {
// Implementation details...
}/// Establishes a WebSocket connection through a SOCKS5 proxy.
///
/// # Arguments
///
/// * `target_url` - The URL of the target WebSocket server.
///
/// # Returns
///
/// A Result containing the WebSocketStream if successful, or an error otherwise.
async fn connect_via_socks_proxy(target_url: &str) -> Result>, Error> {
// Implementation details...
}/// Sends a ping message to an onion DNS service to check connectivity.
///
/// # Returns
///
/// A Result indicating success or error.
async fn ping_onion_dns() -> Result<(), Box> {
// Implementation details...
}/// Saves a binary file asynchronously.
///
/// # Arguments
///
/// * `bin` - The binary content to be saved.
///
/// # Returns
///
/// A Result indicating success or error.
async fn save_file(bin: Vec) -> Result<(), std::io::Error> {
// Implementation details...
}/// Converts a usize to an i32 safely.
///
/// # Arguments
///
/// * `value` - The usize value to be converted.
///
/// # Returns
///
/// A Result containing the converted i32 value or an error if the conversion is not possible.
fn usize_to_i32(value: Result) -> Result {
// Implementation details...
}/// Validates and updates the local blockchain with data from a specified directory.
///
/// # Arguments
///
/// * `path` - The path to the directory containing the blockchain data to be validated and incorporated.
///
/// # Returns
///
/// A boolean indicating whether the operation was successful.
fn create_blockchain(path: String) -> bool {
// Implementation details...
}/// Unzips a tar.gz file asynchronously.
///
/// # Returns
///
/// A Result indicating success or error.
async fn unzip_file() -> Result<(), std::io::Error> {
// Implementation details...
}/// Sends a message to a specified receiver using a WebSocket connection.
///
/// # Arguments
///
/// * `message` - The message to be sent.
/// * `receiver` - The receiver's address.
/// * `type_message` - The type of message to be sent.
///
/// # Returns
///
/// A string response from the receiver.
pub async fn send_a_message(message: String, receiver: String, type_message: i16) -> String {
// Implementation details...
}/// The main function initializes the Tor proxy and starts listening for incoming connections.
#[tokio::main]
pub async fn main() -> tokio::io::Result<()> {
// Implementation details...
}/// Handles incoming WebSocket connections.
///
/// # Arguments
///
/// * `stream` - The TcpStream of the incoming connection.
async fn handle_connection(stream: tokio::net::TcpStream) {
// Implementation details...
}/// Checks the blockchain for synchronization requests or updates from a node.
///
/// # Arguments
///
/// * `text` - The received text message containing the request.
/// * `receiver` - The address of the node that sent the message.
/// * `write` - The WebSocket write half, used to send responses.
///
/// # Returns
///
/// A Result indicating success or error.
async fn check_blockchain_for_the_node(text: String, receiver: String, write: WebSocketStream) -> Result<(), Box> {
// Implementation details...
}/// Compresses and serializes blockchain data into a tar.gz archive.
///
/// # Arguments
///
/// * `first_block` - The first block number to include in the archive.
/// * `last_block` - The last block number to include in the archive.
///
/// # Returns
///
/// A Result containing the binary data of the compressed archive or an error.
fn tar_gz_your_blockchain(first_block: i32, last_block: i32) -> Result, Box> {
// Implementation details...
}```
### fully vm support
```bash
./send_to_vm.sh --vm_name "YourVMName" --snapshot_name "YourSnapshotName" --user "vmUser" --vm_ip "vmIPAddress" --file_to_send "path/to/your/file" --executable_on_vm "/path/on/vm/yourFile" --result_file_on_vm "/path/on/vm/result.txt" --result_file_on_host "path/on/host/result.txt"
```
### Make A VM
jsut run the following command
```bash
./make_a_vm.sh
```
for windows users
```bash
make_a_vm_windows.sh
```