Last active
August 12, 2024 06:27
-
-
Save TestSubjector/efae35941009dd5dc33aa639ff439b3f to your computer and use it in GitHub Desktop.
A very basic implementation of a blockchain in Julia.
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
using SHA | |
using Dates | |
""" | |
An individual block structure | |
""" | |
struct Block | |
index::Int | |
timestamp::DateTime | |
data::String | |
previous_hash::String | |
hash::String | |
""" | |
The constructor which will also create hash for the block. | |
It will use 256 bit encryption for the blockchain's security needs. | |
""" | |
function Block(index, timestamp, data, previous_hash) | |
hash = sha2_256(string(index, timestamp, data, previous_hash)) | |
new(index, timestamp, data, previous_hash, bytes2hex(hash)) | |
end | |
end | |
""" | |
Add another block to the chain. | |
You can't have a blockchain with just one block after all. | |
""" | |
function next_block(tail_block::Block) | |
new_index = tail_block.index + 1 | |
return Block(new_index, Dates.now(), string("This is block ",new_index), tail_block.hash) | |
end | |
# Create the special first block or the head of the blockchain. | |
Blockchain = [Block(0, Dates.now(), "Genesis Block", "0")] | |
println("Genesis Block : 1") | |
println("Hash :", Blockchain[1].hash) | |
# Size of the blockchain | |
Blockchain_limit = 13 | |
# To make addition of blocks to the blockchain non-arbitary (unlike here), | |
# a proof of work task is required. | |
for tail = 1:Blockchain_limit | |
# Link the new block to the chain | |
append!(Blockchain, [next_block(Blockchain[tail])]) | |
# The details of the block | |
println("Block : $(tail+1)") | |
println("Hash :", Blockchain[tail+1].hash) | |
end | |
# Reference - https://medium.com/crypto-currently/lets-build-the-tiniest-blockchain-e70965a248b |
woulschneider
commented
Jul 9, 2019
via email
I am sorry for my ignorance. I am no programmer, just a brazillian
physician. I order to 'avoid' mass adoption, could I use a local blockchain
and do something like exporting to another one, bigger, if needed ?
*André Millet*
Em ter, 9 de jul de 2019 às 12:34, Kumar Prasun <[email protected]>
escreveu:
… @andremillet <https://github.com/andremillet> This is just a quick of
proof-of-concept. But yes, if developed into a proper blockchain tool, it
can be used for EMRs. In fact countries like Estonia and Australia
apparently already use blockchain technology to maintain their EMRs.
Of course getting organisations to agree to store their patients' medical
records on such a system, may well be a bigger challenge than implementing
the code itself.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://gist.github.com/efae35941009dd5dc33aa639ff439b3f?email_source=notifications&email_token=AAEJGSJTRLVZ5BIDXECPF73P6SVWVA5CNFSM4H643ZZ2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFVAFW#gistcomment-2965595>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEJGSKMYHQBZBZKPE7ONCLP6SVWVANCNFSM4H643ZZQ>
.
@andremillet In almost all cases, the blockchain that you would have will (have to) be the same as everyone else's. This is so that everything is in sync. The usefulness of a blockchain is mostly apparent only when it is used by several groups together.
Essentially as you are a healtcare provider, how it will work from your side is that - You upload your patients healtcare information in your existing database. A hash (encryted output) will be generated and sent to the blockchain (authorised by you to receive that hash).
Please have a look at various use cases for blockchain in healthcare and in particular, Use Case #3 which seems to be the most similar to your needs.
If you have any more queries feel free to DM me at [email protected].
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment