coincoin icon indicating copy to clipboard operation
coincoin copied to clipboard

Make the blockchain available for external usage

Open robinmonjo opened this issue 7 years ago • 6 comments

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:

  1. define an API that could work for "every use cases"
  2. document high level API + usage
  3. find a name for the package
  4. namespace the blockchain app with this name
  5. 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 😊

robinmonjo avatar Dec 03 '17 13:12 robinmonjo

  1. Just put it under Coincoin.Blockchain with the package name of coincoin_blockchain

yordis avatar Dec 03 '17 13:12 yordis

  1. What will the blockchain be responsable for?

This is thinking on all the use cases.

yordis avatar Dec 03 '17 13:12 yordis

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 avatar Dec 03 '17 13:12 robinmonjo

@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

yordis avatar Dec 03 '17 13:12 yordis

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" ?

robinmonjo avatar Dec 03 '17 13:12 robinmonjo

"food protocol" type I will fix it BrokeBack

yordis avatar Dec 03 '17 13:12 yordis