coincoin
coincoin copied to clipboard
Make the blockchain available for external usage
The goal is to provide the blockchain part as an hex package so people can reuse it in their own project.
To achieve this we must:
- define an API that could work for "every use cases"
- document high level API + usage
- find a name for the package
- namespace the blockchain app with this name
- follow this guide to publish the app
@yordis the first part I think is to think about an API. For now, the Blockchain app exposes:
A protocol that data we want to store on the chain must follow:
defprotocol Blockchain.BlockData do
@spec hash(t) :: String.t()
def hash(data)
@spec verify(t, [Blockchain.Block.t()]) :: :ok | {:error, String.t()}
def verify(data, chain)
end
A set of functions to interact with the blockchain
@yordis you have a use case in mind, this is perfect to define what APIs you will need. We can then include them in the project. Then we must find a name for the package and namespace it. Waiting for suggestions 😊
- Just put it under
Coincoin.Blockchain
with the package name ofcoincoin_blockchain
- What will the blockchain be responsable for?
This is thinking on all the use cases.
Ok if we put it under Coincoin.Blockchain
we should auto alias it in coincoin so people don't have to type Coincoin.Blockchain.command
every time. Looks like it's doable not sure if it works with releases though ...
The blockchain is responsible for what it is currently:
- communication between peers
- communication protocol (including Proof-of-Work)
- storing data
@robinmonjo yes, about the aliasing. Look my PR I didn't change that piece on your code because I used the alias.
- Will be the P2P be part of the blockchain or could we extract it as well? You know better so think if we can divide as well
- I am not clean about PoW being part of the protocol. What do you mean by that? Specially that technologies like ETH have to move away from PoW for a reason (do not scale when you add it with smart contract shit, nobody will like to do miner work, unless you give them a really high paid transaction)
- storing data, then we need to define a good protocol around it and we should be good to go
Sure we could extract the P2P part too. But this won't have much value by its own without the blockchain logic on top of it.
Blockchains are ran on a network of untrusted peers. Having a mechanism such as PoW or PoS is mandatory in such environment to ensure consensus between peers.
What do you mean about "food protocol" ?
"food protocol" type I will fix it BrokeBack