nxt.account

## Class AccountLedger

- java.lang.Object
- - nxt.account.AccountLedger

-     public class AccountLedger
      extends java.lang.Object

  Maintain a ledger of changes to selected accounts

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `AccountLedger.Event` Account ledger listener events
    `static class` | `AccountLedger.LedgerEntry` Ledger entry
    `static class` | `AccountLedger.LedgerEvent` Ledger events There must be a ledger event defined for each transaction (type,subtype) pair.
    `static interface` | `AccountLedger.LedgerEventId`
    `static class` | `AccountLedger.LedgerHolding` Ledger holdings When adding a new holding, do not change the existing code assignments since they are stored in the holding_type field of the account_ledger table.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `trimKeep` Number of blocks to keep when trimming

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AccountLedger()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `addListener(Listener<AccountLedger.LedgerEntry> listener, AccountLedger.Event eventType)` Add a listener
    `static void` | `clearEntries()` Clear pending ledger entries
    `static void` | `commitEntries()` Commit pending ledger entries
    `static java.util.List<AccountLedger.LedgerEntry>` | `getEntries(long accountId, AccountLedger.LedgerEvent event, long eventId, AccountLedger.LedgerHolding holding, long holdingId, int firstIndex, int lastIndex)` Return the ledger entries sorted in descending insert order
    `static AccountLedger.LedgerEntry` | `getEntry(long ledgerId)` Return a single entry identified by the ledger entry identifier
    `static void` | `init()` Initialization We don't do anything but we need to be called from Nxt.init() in order to register our table
    `static AccountLedger.LedgerEventId` | `newEventId(Block block)`
    `static AccountLedger.LedgerEventId` | `newEventId(long eventId, byte[] eventHash, Chain chain)`
    `static AccountLedger.LedgerEventId` | `newEventId(Transaction transaction)`
    `static boolean` | `removeListener(Listener<AccountLedger.LedgerEntry> listener, AccountLedger.Event eventType)` Remove a listener

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### trimKeep

          public static final int trimKeep

      Number of blocks to keep when trimming

  - ### Constructor Detail

    - #### AccountLedger

          public AccountLedger()

  - ### Method Detail

    - #### init

          public static void init()

      Initialization We don't do anything but we need to be called from Nxt.init() in order to register our table

    - #### addListener

          public static boolean addListener(Listener<AccountLedger.LedgerEntry> listener,
                                            AccountLedger.Event eventType)

      Add a listener
      Parameters:
        `listener` - Listener
        `eventType` - Event to listen for
      Returns:
        True if the listener was added

    - #### removeListener

          public static boolean removeListener(Listener<AccountLedger.LedgerEntry> listener,
                                               AccountLedger.Event eventType)

      Remove a listener
      Parameters:
        `listener` - Listener
        `eventType` - Event to listen for
      Returns:
        True if the listener was removed

    - #### commitEntries

          public static void commitEntries()

      Commit pending ledger entries

    - #### clearEntries

          public static void clearEntries()

      Clear pending ledger entries

    - #### getEntry

          public static AccountLedger.LedgerEntry getEntry(long ledgerId)

      Return a single entry identified by the ledger entry identifier
      Parameters:
        `ledgerId` - Ledger entry identifier
      Returns:
        Ledger entry or null if entry not found

    - #### getEntries

          public static java.util.List<AccountLedger.LedgerEntry> getEntries(long accountId,
                                                                             AccountLedger.LedgerEvent event,
                                                                             long eventId,
                                                                             AccountLedger.LedgerHolding holding,
                                                                             long holdingId,
                                                                             int firstIndex,
                                                                             int lastIndex)

      Return the ledger entries sorted in descending insert order
      Parameters:
        `accountId` - Account identifier or zero if no account identifier
        `event` - Ledger event or null
        `eventId` - Ledger event identifier or zero if no event identifier
        `holding` - Ledger holding or null
        `holdingId` - Ledger holding identifier or zero if no holding identifier
        `firstIndex` - First matching entry index, inclusive
        `lastIndex` - Last matching entry index, inclusive
      Returns:
        List of ledger entries

    - #### newEventId

          public static AccountLedger.LedgerEventId newEventId(long eventId,
                                                               byte[] eventHash,
                                                               Chain chain)

    - #### newEventId

          public static AccountLedger.LedgerEventId newEventId(Transaction transaction)

    - #### newEventId

          public static AccountLedger.LedgerEventId newEventId(Block block)