Module crypt.api

Interface IBlock


public interface IBlock
The interface IBlock represents a block in a blockchain system.

This interface defines methods for getting and setting the data, hash, Merkle root, previous block hash, timestamp, transactions, and tries count associated with a blockchain block.

  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the data contained in the block.
    byte[]
    Gets the hash of the block.
    int
    Gets the number of leading zeros in the block's hash (used for proof-of-work).
    byte[]
    Gets the Merkle root of the block.
    byte[]
    Gets the hash of the previous block in the blockchain.
    long
    Gets the timestamp when the block was created.
    Gets the list of transactions contained in the block.
    long
    Gets the number of tries made to generate the block (used for proof-of-work).
    void
    Sets the data for the block.
    void
    setHash(byte[] hash)
    Sets the hash of the block.
    void
    setMerkleRoot(byte[] merkleRoot)
    Sets the Merkle root of the block.
    void
    setPreviousBlockHash(byte[] previousBlockHash)
    Sets the hash of the previous block in the blockchain.
    void
    setTimestamp(long timestamp)
    Sets the timestamp for when the block was created.
    void
    Sets the list of transactions for the block.
    void
    setTries(long tries)
    Sets the number of tries made to generate the block.
  • Method Details

    • getData

      String getData()
      Gets the data contained in the block.
      Returns:
      the data as a String
    • setData

      void setData(String data)
      Sets the data for the block.
      Parameters:
      data - the data to set, as a String
    • getHash

      byte[] getHash()
      Gets the hash of the block.
      Returns:
      the hash as a byte array
    • setHash

      void setHash(byte[] hash)
      Sets the hash of the block.
      Parameters:
      hash - the hash to set, as a byte array
    • getLeadingZerosCount

      int getLeadingZerosCount()
      Gets the number of leading zeros in the block's hash (used for proof-of-work).
      Returns:
      the count of leading zeros
    • getMerkleRoot

      byte[] getMerkleRoot()
      Gets the Merkle root of the block.
      Returns:
      the Merkle root as a byte array
    • setMerkleRoot

      void setMerkleRoot(byte[] merkleRoot)
      Sets the Merkle root of the block.
      Parameters:
      merkleRoot - the Merkle root to set, as a byte array
    • getPreviousBlockHash

      byte[] getPreviousBlockHash()
      Gets the hash of the previous block in the blockchain.
      Returns:
      the previous block's hash as a byte array
    • setPreviousBlockHash

      void setPreviousBlockHash(byte[] previousBlockHash)
      Sets the hash of the previous block in the blockchain.
      Parameters:
      previousBlockHash - the previous block's hash to set, as a byte array
    • getTimestamp

      long getTimestamp()
      Gets the timestamp when the block was created.
      Returns:
      the timestamp as a long value
    • setTimestamp

      void setTimestamp(long timestamp)
      Sets the timestamp for when the block was created.
      Parameters:
      timestamp - the timestamp to set, as a long value
    • getTransactions

      List<ITransaction> getTransactions()
      Gets the list of transactions contained in the block.
      Returns:
      the list of transactions
    • setTransactions

      void setTransactions(List<ITransaction> transactions)
      Sets the list of transactions for the block.
      Parameters:
      transactions - the list of transactions to set
    • getTries

      long getTries()
      Gets the number of tries made to generate the block (used for proof-of-work).
      Returns:
      the number of tries as a long value
    • setTries

      void setTries(long tries)
      Sets the number of tries made to generate the block.
      Parameters:
      tries - the number of tries to set, as a long value