code: private void insertCurrentStoredBlockIntoList() {
      // index < 0 - block is already in the DN's list
      if (currentStoredBlock == null || currentStoredBlockIndex < 0)
        return;
  
      if (head == null) {
        // local list is empty,
        // make head and tail point to the input block
        head = currentStoredBlock;
        headIndex = currentStoredBlockIndex;
  
        tail = currentStoredBlock;
        tailIndex = currentStoredBlockIndex;
  
        // for sanity, make sure the block is not pointing to anything
        head.setNext(currentStoredBlockIndex, null);
        head.setPrevious(currentStoredBlockIndex, null);
      } else {
        // connect input block with current head
        head.setPrevious(headIndex, currentStoredBlock);
        currentStoredBlock.setNext(currentStoredBlockIndex, head);
  
        // stored block is the new head
        head = currentStoredBlock;
        headIndex = currentStoredBlockIndex;
      }
      // increment number of blocks in the local list
      addedBlocks++;
  
      // clear the current stored block information
      resetCurrentStoredBlock();
    }
docs: Insert the current stored block into the local list of blocks belonging to
  the datanode descriptor.