blockchain – How bitcoin network manages to append block in front of parallel blocks added by multiple nodes at the same time

Well, according to my research, After solving the cryptographic hash, when the multiple nodes broadcast the block at the same time as a suggestion to be the next block in the chain. How and why the Bitcoin network add all those blocks to the chain? For instance, if the 3 blocks are added parallel at the same time. So, now the next block will append which Block-chain 1st, 2nd or third? Please explain in detail how future blocks will append. Moreover, How the network will handle this situation.

Please let me know if my concept is wrong. I will appreciate your guidance. Thanks

bitcoin core – How Nodes suggests for what the next block in the chain should be by solving cryptographic hash by random guesses

Well, According to my research, Any node can collect a set up unconfirmed transactions into a block and broadcast to the rest of the network as a suggestion for what the next block in the chain should be, by solving the cryptographic hash by random guesses. Moreover, the hash function creates something like a 32byte number might be using SHA256. So, I want to know who creates random numbers? and how nodes do guessing?

Please let me know if my concept is wrong. I will appreciate your guidance. Thanks

blockchain fork – Which blk*.dat file contains a particular block?

Is there a way to find out which blk*.dat file contains a particular block?

For example, it would be useful to know which *.dat file contains block 478558, which is the point where BCH forked from BTC. As both share all the prior blocks, when running the forked node, it would save a lot of bandwith to just copy the block files from BTC to the BCH data directory and reindex them (with the -reindex option), rather than having to re-download them all over again.

magento2 – Overwriting block is not used in 2.4.1

I’m simply trying to overwrite the following method with a preference, but I can’t get it work after over 3 hours of trying and scratching my head at the sheer amount of effort required to do such a simple thing. I’ve read about a dozen posts and articles on how to do this, but none of the suggested solutions work.

Method to overwrite MagentoCatalogBlockProductListProduct::_getProductCollection to add additional filtering on the product collection displayed on catalogsearch/result/?q=xyz.

Module is correctly set up and shows to be enabled through CLI.

Vendor/Module/etc/di.xml (tried etc/frontend/di.xml also):

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="MagentoCatalogBlockProductListProduct" type="VendorModuleBlockProductListProduct" />
</config>

Testing the overwrite with the ObjectManager yields my class:

<?php
require_once 'app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$sample = $bootstrap->getObjectManager()->create('MagentoCatalogBlockProductListProduct');
var_dump(get_class($sample)); 
// Prints VendorModuleBlockProductListProduct

I have the module block at Vendor/Module/Block/Product/ListProduct.php, but it does not get used.
I have also tried adding my own layout update at Vendor/Module/view/frontend/layout/catalog_category_view.xml in an attempt to try filtering our some results on the template level, but it does not use my template.

<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
    <referenceBlock name="category.products.list">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Vendor_Module::product-list.phtml</argument>
        </action>
    </referenceBlock>
</layout>

I have tried the any combinations of the following each time file changes are made:

  • All cache turned off
  • cache:clean/flush
  • setup:di:compile
  • rm -rf generated
  • print-die methods and xdebug breakpoints on my files

I have noticed:

  • Manually using ObjectManager yields my class.
  • My module is turned on (module:status)
  • di.xml and catalog_category_view.xml are indeed read. Having invalid XML breaks the page.
  • Xdebug will not stop at my files, but stops on the core Magento_Catalog files.

Any idea what’s going on?

Formatted text, code block in draw.io

I want to add JSON code snippets to my diagram in draw.io. When I use copy/paste to a text box, the indented spaces/tabs get lost.

Does anyone know how to copy formatted snippets from notepad++/VS Code to draw.io?

algorithms – Consider the game move the block slide puzzle

Consider the game Move the Block (gameplay
https://www.youtube.com/watch?v=6d0NcUougD4). Move the Block : Slide Puzzle is a simple
game whose goal is sliding block puzzle game. The game instructions are extremely simple
(https://www.apkonline.net/games/puzzle/move-the-block-slide-puzzle-online-android):
 You have to move the red block in order to the exit.
 You can move horizontal blocks from side to side
 You can move vertical blocks up and down.
The game has also the following characteristics:
 Your representation of the game should take into account that the grid size i.e. the
number of rows and columns would be as follows:
o number of rows >= 7
o number of columns >= 8
 There could be an arbitrary number of blocks in the puzzle, however, the puzzle will
always have a solution
 The puzzle could also have many solutions
 You will be given the best possible solution
 Every slide will cost +1
For the game described above do the following
a) Describe the agent using the PEAS framework. Also describe the characteristics of the
task environment.
b) Model this game as a search problem. You have to describe the following:
i. Data structure to be used to represent the state
ii. State space
iii. Initial State
Page 3 of 4
Page 3 of 4
iv. Successor Function
v. Actions
vi. Goal Test
c) Calculate the branching factor and possible size of the state space in terms of grid size
and blocks available.
d) Use the following puzzle to show the working of the BFS and IDS for upto depth = 3.
Show the contents of the frontier list, and the selected node at every step.
e) Develop two admissible heuristics for this problem. Also show that they are admissible.
f) Use the heuristics developed in part (e) to run A* search and Greedy Search to a depth =
5. Show the contents of the frontier list, and the selected node at every step.
g) Describe in your words why UCS is optimal

What is the purpose of storing difficulty in block?

The difficulty is calculated by the node itself, after every block addition. So why does every block contain unnecessary information about difficulty if it is anyway calculated by the node?

block – Is every copy of the blockchain the same? If I have an error within file should I be able to copy this file from a backup and reindex chainstate?

I recently moved the first 2000 files of my blockchain from the SSD to a HDD. The HDD gets mounted in /mnt/ext.

I tried a bitcoind -reindex-chainstate to be sure everything still works but now it is giving an error:

2020-11-26T12:52:24Z ERROR: ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for CBlockIndex(pprev=0x44288c0, nHeight=255, merkle=4309bfeed77a70f309da08bcf8948906b9cc26120c0b0ef86e0ac67284bbd79e, hashBlock=00000000d0a75c861fabf9ff7b92022f60e4afeed9331fe5aa073d8e4706fe3c) at FlatFilePos(nFile=0, nPos=58808)
2020-11-26T12:52:24Z *** Failed to read block

Now I have several questions. I think nFile=0 means that the block is in blk00000.dat and rev00000.dat. Am I right?

So I copied this file again from a backup of the blockchain. This is from a second node. But I would suspect the files are the same, right?

But I get the exact same error at the same position – even with a new -reindex-chainstate.

I can see in the log that all blocks up until number 254 get indexed but each time it fails on block with height 255.

I think those old files contain always the same blocks. How can it be 254 blocks are correct but it fails on the next one?

Could this simply be a problem of the mount?

Block page access in GitHub Pages

I want to know how can I block page access in GitHub Pages. For example I cannot access to this website.

8 – Custom block disable caching?

I’ve created a custom module to show On This Days in a block but they are not changing each day until I flush the caches.

I call the entity:

public function build() {
    $query = Drupal::entityQuery('node');
    $query->condition('status', 1);
    $query->condition('type', 'on_this_day');
    $query->condition('field_filter_date', '-' . date("m-d"), 'CONTAINS');
    $entity_ids = $query->execute();

and then return from the build function like this:

return array(
        '#markup' => $content,
        '#cache' => array(
            'max-age' => 0,
        ),

Any ideas?
I’m thinking entity cache or something but I’m quite new to this and not too sure