nxt

## Class AccountLedger

- java.lang.Object
- - nxt.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 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 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 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

    - #### 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

    - #### 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