datastructures/blockchain.rb
def save
    json = @chain.to_json
    FileUtils.mkdir_p("data") unless Dir.exists?("data")
    File.open("data/blockchain.json","w") do |f|
      f.write(json)
    end
  end
# Save the blockchain as a JSON file
Save the blockchain as a JSON file
Save the blockchain as a JSON file
def save
    json = @chain.to_json
    FileUtils.mkdir_p("data") unless Dir.exists?("data")
    File.open("data/blockchain.json","w") do |f|
      f.write(json)
    end
  end
def save json = @chain . to_json FileUtils . mkdir_p ( "data" ) unless Dir . exists? ( "data" ) File . open ( "data/blockchain.json" , "w" ) do | f | f . write ( json ) end end
Save the blockchain as a JSON file
Save the blockchain as a JSON file