robinmonjo / coincoin

Blockchain based cryptocurrency proof-of-concept in Elixir. Feedback welcome
402 stars 54 forks source link

Make the blockchain available for external usage #27

Open robinmonjo opened 6 years ago

robinmonjo commented 6 years ago

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 😊

yordis commented 6 years ago
  1. Just put it under Coincoin.Blockchain with the package name of coincoin_blockchain
yordis commented 6 years ago
  1. What will the blockchain be responsable for?

This is thinking on all the use cases.

robinmonjo commented 6 years ago

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:

yordis commented 6 years ago

@robinmonjo yes, about the aliasing. Look my PR I didn't change that piece on your code because I used the alias.

robinmonjo commented 6 years ago

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

yordis commented 6 years ago

"food protocol" type I will fix it BrokeBack