Skip to content
Snippets Groups Projects

Resolve "Récupération des blocs"

Merged JAUJAY Augustin requested to merge 186-recuperation-des-blocs into dev
2 files
+ 6
6
Compare changes
  • Side-by-side
  • Inline

Files

+ 6
6
@@ -41,21 +41,21 @@ defmodule BDD do
n -> n
end
lastLocalBlock..currentBlock["number"] # TODO : gérer le cas où la bdd est vide
|> Enum.chunk_every(1000)
lastLocalBlock..50 # currentBlock["number"]
|> Enum.chunk_every(5000)
|> Enum.map(fn chk ->
{List.first(chk), List.last(chk)} |> IO.inspect
# Putting the new blocks in the local database
case :httpc.request(:get, {@base_url ++ '/blockchain/blocks/' ++ to_charlist(1000) ++ '/' ++ to_charlist(List.first(chk)), []}, [], []) do
case :httpc.request(:get, {@base_url ++ '/blockchain/blocks/' ++ to_charlist(List.last(chk) - List.first(chk)) ++ '/' ++ to_charlist(List.first(chk)), []}, [], []) do
{:ok, {{_, 200, 'OK'}, _headers, '[]'}} ->
Logger.info('Filling DB : No blocks to get from remote g1-test node')
{:ok, {{_, 200, 'OK'}, _headers, body}} ->
Logger.info('Filling : DB : Successfully got blocks '
Logger.info('Filling DB : Successfully got blocks '
++ to_charlist(List.first(chk))
++ ' to '
++ to_charlist(List.last(chk))
++ ' from remote g1-test node')
++ ' from '
++ @base_url)
Poison.decode!(body) |> Enum.map(fn b -> :dets.insert(:block, {b["number"], b}) end)
error ->
Loading