izqui / blockchain

A basic blockchain implementation written in Go
842 stars 246 forks source link

Transaction - Proof-of-Work not required. #6

Open euforia opened 7 years ago

euforia commented 7 years ago

Based on Satoshi's paper here - https://bitcoin.org/bitcoin.pdf though blocks have proof-of-work transactions do not. The code here checks the POW on the transactions as well - https://github.com/izqui/blockchain/blob/master/core/transaction.go#L58

Am I missing something here? Please let me know. Thank you in advance.

izqui commented 7 years ago

You are certainly right, this was made as an experiment and I added POW everywhere, the thought process was, in order to create a transaction, you need to do some work as there isn't a native token implemented with which pay fees to 'miners'. To reduce spam.

Also, this isn't necessarily a Bitcoin clone but a generic blockchain implementation. That being said, I'm open to discussion and to changing it if it makes more sense!

euforia commented 7 years ago

Thank you for the response. I completely understand the thought process and was also looking at it from the same perspective. I was referencing the original paper just to understand and validate the seen behaviour (non-official RFC if you may).

I am trying to make it into a re-usable general purpose library and wanted to try to follow the official "RFC" where ever possible.

I've broken out the the key management, transport and state machine into interfaces.

The state machine would be user implemented and would get called each time a valid block is available. The transport interface would handle all network operations

For key management - The chain itself would have an associated keypair and each user in turn would also have their own keypair with which the transactions would get signed. This would require some sort of key management interface, which I am also looking at.

This way the user would have flexibility in terms of implementing the different pieces as needed or the default interfaces.

Please let me know what your thoughts are. Cheers.