Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
blockchain_CS765_HW1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Saswat
blockchain_CS765_HW1
Commits
417aca85
Commit
417aca85
authored
Feb 02, 2024
by
Abhishek Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Init files
parents
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
0 deletions
+67
-0
blockchain.py
blockchain.py
+19
-0
network.py
network.py
+23
-0
node.py
node.py
+11
-0
simulate.py
simulate.py
+14
-0
No files found.
blockchain.py
0 → 100644
View file @
417aca85
class
Block
:
def
__init__
(
self
,
ID
,
transactions
,
previous_block_ID
):
# Initialize block attributes
class
Blockchain
:
def
__init__
(
self
):
# Initialize blockchain attributes
def
mine_block
(
peer
,
blockchain
,
longest_chain
):
# Simulate PoW mining and block creation
def
validate_block
(
peer
,
block
):
# Validate transactions in the block
def
resolve_forks
(
peer
,
blockchain
,
longest_chain
):
# Resolve forks and update the longest chain
def
update_tree_file
(
peer
,
blockchain
):
# Update tree file with block information for each node
network.py
0 → 100644
View file @
417aca85
from
node
import
Node
class
Network
:
def
__init__
(
self
,
n
):
self
.
n
=
n
pass
def
initialise_nodes
():
pass
def
create_network
(
peers
):
# Create a connected graph of peers
# Ensure each peer has 3 to 6 connections
pass
def
calculate_latency
(
sender
,
receiver
,
message_size
):
# Calculate latency based on provided formula
pass
def
forward_transaction
(
sender
,
receiver
,
transaction
):
# Forward transaction from sender to receiver if conditions are met
pass
\ No newline at end of file
node.py
0 → 100644
View file @
417aca85
class
Node
:
def
__init__
(
self
,
ID
,
cpuType
,
speed
,
balance
):
# Initialize node attributes
self
.
balance
=
0
# intialize random
self
.
nodeId
=
0
# initialize random
self
.
cpuType
=
CPU_type
def
generate_transaction
(
peer
):
# Generate a transaction for the given peer
# Format: "TxnID: IDx pays IDy C coins"
pass
simulate.py
0 → 100644
View file @
417aca85
class
Event
:
# time
# operation
class
EventSimulator
:
def
__init__
(
self
):
# max_time of simulation
# queue of events
# create and initialise a network
def
startSimulation
(
self
):
# run a loop till queue is empty / time runouts
# push new events from triggers into the queue
pass
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment