<commit_before>package com.yoghurt.crypto.transactions.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.yoghurt.crypto.transactions.client.di.BitcoinPlaceRouter;
import com.yoghurt.crypto.transactions.client.util.FormatUtil;
import com.yoghurt.crypto.transactions.client.util.block.BlockEncodeUtil;
import com.yoghurt.crypto.transactions.client.util.transaction.TransactionEncodeUtil;
import com.yoghurt.crypto.transactions.client.widget.BlockHexViewer;
import com.yoghurt.crypto.transactions.client.widget.BlockViewer;
import com.yoghurt.crypto.transactions.client.widget.HashHexViewer;
import com.yoghurt.crypto.transactions.client.widget.TransactionHexViewer;
import com.yoghurt.crypto.transactions.client.widget.ValueViewer;
import com.yoghurt.crypto.transactions.shared.domain.Block;
import com.yoghurt.crypto.transactions.shared.domain.BlockInformation;
import com.yoghurt.crypto.transactions.shared.domain.RawBlockContainer;
import com.yoghurt.crypto.transactions.shared.domain.RawTransactionContainer;
import com.yoghurt.crypto.transactions.shared.domain.Transaction;

@Singleton
public class BlockViewImpl extends AbstractBlockchainView implements BlockView {
  interface BlockViewImplUiBinder extends UiBinder<Widget, BlockViewImpl> {}

  private static final BlockViewImplUiBinder UI_BINDER = GWT.create(BlockViewImplUiBinder.class);

  @UiField FlowPanel extraInformationContainer;
  @UiField Label notFoundLabel;

  @UiField HashHexViewer blockHashViewer;
  @UiField HashHexViewer coinbaseHashViewer;

  @UiField ValueViewer versionViewer;
  @UiField(provided = true) BlockViewer previousBlockHashViewer;
  @UiField ValueViewer merkleRootViewer;
  @UiField ValueViewer timestampViewer;
  @UiField ValueViewer bitsViewer;
  @UiField ValueViewer nonceViewer;

  @UiField ValueViewer heightViewer;
  @UiField ValueViewer numConfirmationsViewer;
  @UiField ValueViewer numTransactionsViewer;
  @UiField(provided = true) BlockViewer nextBlockViewer;
  @UiField ValueViewer sizeViewer;

  @UiField BlockHexViewer blockHexViewer;
  @UiField TransactionHexViewer coinbaseHexViewer;

  @Inject
  public BlockViewImpl(final BitcoinPlaceRouter router) {
    nextBlockViewer = new BlockViewer(router);
    previousBlockHashViewer = new BlockViewer(router);

    initWidget(UI_BINDER.createAndBindUi(this));
  }

  @Override
  public void setBlock(final BlockInformation blockInformation) {
    final Transaction coinbase = getTransactionFromHex(blockInformation.getRawCoinbaseTransaction());
    final Block block = getBlockFromHex(blockInformation.getRawBlockHeaders());


    final RawTransactionContainer rawTransaction = new RawTransactionContainer();
    final RawBlockContainer rawBlock = new RawBlockContainer();

    try {
      BlockEncodeUtil.encodeBlock(block, rawBlock);
      TransactionEncodeUtil.encodeTransaction(coinbase, rawTransaction);
    } catch (final Throwable e) {
      e.printStackTrace();
      // Eat.
    }

    blockHashViewer.setHash(block.getBlockHash());
    coinbaseHashViewer.setHash(coinbase.getTransactionId());

    versionViewer.setValue(block.getVersion());
    previousBlockHashViewer.setValue(block.getPreviousBlockHash());
    merkleRootViewer.setValue(block.getMerkleRoot());
    timestampViewer.setValue(FormatUtil.formatDateTime(block.getTimestamp()));
    bitsViewer.setValue(block.getBits());
    nonceViewer.setValue(block.getNonce());

    blockHexViewer.setValue(rawBlock.entrySet());
    notFoundLabel.setVisible(blockInformation == null);
    extraInformationContainer.setVisible(blockInformation != null);

    coinbaseHexViewer.setValue(rawTransaction);

    heightViewer.setValue(blockInformation.getHeight());
    numConfirmationsViewer.setValue(blockInformation.getNumConfirmations());
    numTransactionsViewer.setValue(blockInformation.getNumTransactions());
    nextBlockViewer.setValue(blockInformation.getNextBlockHash());
    sizeViewer.setValue(blockInformation.getSize());
  }
}<commit_msg>Aesthetics to block UI<commit_after>package com.yoghurt.crypto.transactions.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.yoghurt.crypto.transactions.client.di.BitcoinPlaceRouter;
import com.yoghurt.crypto.transactions.client.util.FormatUtil;
import com.yoghurt.crypto.transactions.client.util.block.BlockEncodeUtil;
import com.yoghurt.crypto.transactions.client.util.transaction.TransactionEncodeUtil;
import com.yoghurt.crypto.transactions.client.widget.BlockHexViewer;
import com.yoghurt.crypto.transactions.client.widget.BlockViewer;
import com.yoghurt.crypto.transactions.client.widget.HashHexViewer;
import com.yoghurt.crypto.transactions.client.widget.TransactionHexViewer;
import com.yoghurt.crypto.transactions.client.widget.ValueViewer;
import com.yoghurt.crypto.transactions.shared.domain.Block;
import com.yoghurt.crypto.transactions.shared.domain.BlockInformation;
import com.yoghurt.crypto.transactions.shared.domain.RawBlockContainer;
import com.yoghurt.crypto.transactions.shared.domain.RawTransactionContainer;
import com.yoghurt.crypto.transactions.shared.domain.Transaction;

@Singleton
public class BlockViewImpl extends AbstractBlockchainView implements BlockView {
  interface BlockViewImplUiBinder extends UiBinder<Widget, BlockViewImpl> {}

  private static final BlockViewImplUiBinder UI_BINDER = GWT.create(BlockViewImplUiBinder.class);

  @UiField FlowPanel extraInformationContainer;
  @UiField Label notFoundLabel;

  @UiField HashHexViewer blockHashViewer;
  @UiField HashHexViewer coinbaseHashViewer;

  @UiField ValueViewer versionViewer;
  @UiField(provided = true) BlockViewer previousBlockHashViewer;
  @UiField ValueViewer merkleRootViewer;
  @UiField ValueViewer timestampViewer;
  @UiField ValueViewer bitsViewer;
  @UiField ValueViewer nonceViewer;

  @UiField ValueViewer heightViewer;
  @UiField ValueViewer numConfirmationsViewer;
  @UiField ValueViewer numTransactionsViewer;
  @UiField(provided = true) BlockViewer nextBlockViewer;
  @UiField ValueViewer sizeViewer;

  @UiField BlockHexViewer blockHexViewer;
  @UiField TransactionHexViewer coinbaseHexViewer;

  @Inject
  public BlockViewImpl(final BitcoinPlaceRouter router) {
    nextBlockViewer = new BlockViewer(router);
    previousBlockHashViewer = new BlockViewer(router);

    initWidget(UI_BINDER.createAndBindUi(this));
  }

  @Override
  public void setBlock(final BlockInformation blockInformation) {
    final Transaction coinbase = getTransactionFromHex(blockInformation.getRawCoinbaseTransaction());
    final Block block = getBlockFromHex(blockInformation.getRawBlockHeaders());


    final RawTransactionContainer rawTransaction = new RawTransactionContainer();
    final RawBlockContainer rawBlock = new RawBlockContainer();

    try {
      BlockEncodeUtil.encodeBlock(block, rawBlock);
      TransactionEncodeUtil.encodeTransaction(coinbase, rawTransaction);
    } catch (final Throwable e) {
      e.printStackTrace();
      // Eat.
    }

    blockHashViewer.setHash(block.getBlockHash());
    coinbaseHashViewer.setHash(coinbase.getTransactionId());

    versionViewer.setValue(block.getVersion());
    previousBlockHashViewer.setValue(block.getPreviousBlockHash());
    merkleRootViewer.setValue(block.getMerkleRoot());
    timestampViewer.setValue(FormatUtil.formatDateTime(block.getTimestamp()));
    bitsViewer.setValue(block.getBits());
    nonceViewer.setValue(block.getNonce());

    blockHexViewer.setValue(rawBlock.entrySet());
    notFoundLabel.setVisible(blockInformation == null);
    extraInformationContainer.setVisible(blockInformation != null);

    coinbaseHexViewer.setValue(rawTransaction);

    heightViewer.setValue(blockInformation.getHeight());
    numConfirmationsViewer.setValue(blockInformation.getNumConfirmations());
    numTransactionsViewer.setValue(blockInformation.getNumTransactions());
    nextBlockViewer.setValue(blockInformation.getNextBlockHash().toUpperCase());
    sizeViewer.setValue(blockInformation.getSize());
  }
}
{'fraction_non_alphanumeric': 0.09279794560522937, 'fraction_numerical': 0.0, 'mean_word_length': 6.35450643776824, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1095044', 'n_tokens_mistral': 2551, 'n_tokens_neox': 2512, 'n_words': 371}