All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scalar.dl.ledger.statemachine.Ledger Maven / Gradle / Ivy

The newest version!
package com.scalar.dl.ledger.statemachine;

import com.scalar.dl.ledger.database.AssetFilter;
import java.util.List;
import java.util.Optional;

/**
 * A tamper-evident ledger for storing histories of {@link Asset}s.
 *
 * @author Hiroyuki Yamada
 */
public interface Ledger {

  /**
   * Retrieves the latest {@link Asset} entry (an asset entry with the largest age) from the ledger
   * with the specified asset ID.
   *
   * @param assetId an asset ID
   * @return an {@code Optional} with the returned asset
   */
  Optional> get(String assetId);

  /**
   * Retrieves a list of {@link Asset} entries from the ledger with the specified {@link
   * AssetFilter}.
   *
   * @param filter a condition to filter asset
   * @return a list of asset entries which passed the filtering
   */
  List> scan(AssetFilter filter);

  /**
   * Creates/Appends an {@link Asset} entry to the ledger. The initial entry is marked as age 0 and
   * new entry is appended with an incremented age.
   *
   * @param assetId an asset ID to create/append
   * @param data asset data
   */
  void put(String assetId, T data);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy