<prompt> Tekeleza blockchain rahisi katika Ruby, ikiwa ni pamoja na utendaji wa msingi wa madini na uthibitishaji wa shughuli.  <response>: Huu hapa ni utekelezaji rahisi wa blockchain katika Ruby, ikiwa ni pamoja na utendaji wa msingi wa madini na uthibitishaji wa shughuli:rubizinahitaji digestdarasa Block attr_reader :index, :muhuri wa wakati, :data, :hashi_iliyopita, :hashi def anzisha index, data, uliopita_hash index index timestamp Time.now.to_i data data hashi_iliyopita heshi_iliyopita hash hesabu_hashi mwisho def hesabu_hash Digest::SHA256.hexdigestindextimestampdatahashi_iliyopita mwishomwishodarasa Blockchain attr_reader :chain def anzisha mnyororo create_genesis_block mwisho def create_genesis_block Block.new0, Genesis Block, 0 mwisho def add_blockdata new_block data, chain-1.hash chain.pushblock_mpya mwisho def is_valid? kwa mimi katika sasa_block chaini previous_block mnyororoi - 1 rudisha sivyo ikiwa current_block.hash ! current_block.calculate_hash rudisha sivyo ikiwa current_block.previous_hash ! previous_block.hash mwisho kweli mwishomwisho Jaribu blockchainblockchain Blockchain.newblockchain.add_blockData ya Muamala 1blockchain.add_blockData ya Muamala 2inaweka Blockchain halali? blockchain.is_valid?inaweka Kuharibu data ...blockchain.chain1.instance_variable_set:data, Tampered Datainaweka Blockchain halali? blockchain.is_valid?Msimbo huu unafafanua aina mbili: Block na Blockchain. Darasa la Block linawakilisha block moja kwenye blockchain, na darasa la Blockchain linawakilisha msururu mzima.Darasa la Block lina mbinu za kukokotoa heshi yake kulingana na data yake. Darasa la Blockchain huanzishwa kwa uzuiaji wa mwanzo na lina mbinu za kuongeza vizuizi vipya kwenye msururu na kuthibitisha uadilifu wa mnyororo.Ili kujaribu blockchain, tunaunda mfano mpya wa darasa la Blockchain, kuongeza vizuizi, na kisha kuangalia ikiwa mnyororo ni sahihi. Pia tunaharibu data katika mojawapo ya vizuizi na kuthibitisha upya msururu ili kuonyesha jinsi mchakato wa uthibitishaji unavyofanya kazi. 