You are viewing a single comment's thread from:

RE: Exploring the Bitcoin Blockchain with Elixir and Phoenix

in #bitcoin7 years ago (edited)

This is the best introduction I could find to both Phoenix and Blockchain.

But it assumes too much familiarity. There are places where it's not clear exactly what you have to do.

After
"mix phx.new hello_blockchain --no-ecto"
it should say how to respond to the question "Install dependencies Y/n?"

Before
"mix phx.gen.html Blockchain Header headers --no-schema"
it should say
"cd hello_blockchain"

When it says
"Let’s remove the auto-generated contents of Blockchain and copy over the bitcoin_rpc function."
it should say which file it is referring to.

"Be sure to add dependencies on :httpoison and :poison, and set up your :bitcoin_url in your configuration file."
Where do you add dependencies, and how?
Which file is your configuration file, how do you deduce what :bitcoin_url should be set up to, and how do you set it up?

(Reading your post "Controlling a Bitcoin Node with Elixir", http://www.petecorey.com/blog/2017/09/04/controlling-a-bitcoin-node-with-elixir, makes it clear - but it would do no harm to repeat the information in the current post).

"let’s add their new routes to our router"
I know it's router.ex, but someone else might not.

"We’ll start with the BlockController"
I couldn't find it. Then I realised it's because I hadn't run
"mix phx.gen.html Blockchain Blocks blocks --no-schema"
because I'd missed it because it is not in a fixed width font like the other commands.

Once I'd run that command, I had
lib/hello_blockchain_web/controllers/blocks_controller.ex
and could follow the instructions about modifying "BlockController". Except, at this point, as a result of copying, pasting and running the commands above, I realised I had references to both BlockController and BlocksController in my project. I guessed it should be just "BlocksController", but I looked in https://github.com/pcorey/hello_blockchain, and found it was "BlockController", in files
test/hello_blockchain_web/controllers/block_controller_test.exs
and
lib/hello_blockchain_web/controllers/block_controller.ex
In fact there are no files beginning "blocks", and no classes beginning "Blocks".

I think the section beginning "Similarly, the index function in the HeaderController" implies deleting all methods in
lib/hello_blockchain_web/controllers/header_controller.ex
and replacing them with the index and show methods described in that section, but if so, I think it should say so.

"There’s one final route we need to implement. When a user hits our application for the first time, they’ll land on the Phoenix landing page. Instead, let’s show them the most recent block header:

def index..."

Again, it would help if it said which file this method should be implemented in.

And "<%= Poison.encode!(@block, pretty: true) %>".

And when it says change app.css, it would be helpful if it said whether that is
priv/static/css/app.css
or
assets/css/app.css
although, on second thoughts, it's obviously the latter.

I hope you don't find this too pernickety. Most of it I figured out, but I did Rails for years. I suspect some readers would get it all straight away, and some would get lost.

Thanks for your attention.

EDIT - just one more point. bitcoind now says rpcuser and rpcpassword will soon be deprecated, which you use in http://www.petecorey.com/blog/2017/09/04/controlling-a-bitcoin-node-with-elixir/

EDIT: 'getinfo' has also been deprecated. It's now
curl --data-binary '{"jsonrpc":"1.0","method":"getblockchaininfo","params":[]}' http://user:pass@localhost:8332/