// Copyright 2015 Stellar Development Foundation and contributors. Licensed // under the Apache License, Version 2.0. See the COPYING file at the root // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0 %#include "generated/Stellar-transaction.h" namespace stellar { typedef opaque UpgradeType<128>; /* StellarValue is the value used by SCP to reach consensus on a given ledger */ struct StellarValue { Hash txSetHash; // transaction set to apply to previous ledger uint64 closeTime; // network close time // upgrades to apply to the previous ledger (usually empty) // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop // unknown steps during consensus if needed. // see notes below on 'LedgerUpgrade' for more detail UpgradeType upgrades<4>; // reserved for future use union switch (int v) { case 0: void; } ext; }; /* The LedgerHeader is the highest level structure representing the * state of a ledger, cryptographically linked to previous ledgers. */ struct LedgerHeader { uint32 ledgerVersion; // the protocol version of the ledger Hash previousLedgerHash; // hash of the previous ledger header StellarValue scpValue; // what consensus agreed to Hash txSetResultHash; // the TransactionResultSet that led to this ledger Hash bucketListHash; // hash of the ledger state uint32 ledgerSeq; // sequence number of this ledger int64 totalCoins; // total number of stroops in existence int64 feePool; // fees burned since last inflation run uint32 inflationSeq; // inflation sequence number uint64 idPool; // last used global ID, used for generating objects uint32 baseFee; // base fee per operation in stroops uint32 baseReserve; // account base reserve in stroops Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back // in time without walking the chain back ledger by ledger // each slot contains the oldest ledger that is mod of // either 50 5000 50000 or 500000 depending on index // skipList[0] mod(50), skipList[1] mod(5000), etc // reserved for future use union switch (int v) { case 0: void; } ext; }; /* Ledger upgrades note that the `upgrades` field from StellarValue is normalized such that it only contains one entry per LedgerUpgradeType, and entries are sorted in ascending order */ enum LedgerUpgradeType { LEDGER_UPGRADE_VERSION = 1, LEDGER_UPGRADE_BASE_FEE = 2 }; union LedgerUpgrade switch (LedgerUpgradeType type) { case LEDGER_UPGRADE_VERSION: uint32 newLedgerVersion; // update ledgerVersion case LEDGER_UPGRADE_BASE_FEE: uint32 newBaseFee; // update baseFee }; /* Entries used to define the bucket list */ union LedgerKey switch (LedgerEntryType type) { case ACCOUNT: struct { AccountID accountID; } account; case TRUSTLINE: struct { AccountID accountID; Currency currency; } trustLine; case OFFER: struct { AccountID accountID; uint64 offerID; } offer; }; enum BucketEntryType { LIVEENTRY = 0, DEADENTRY = 1 }; union BucketEntry switch (BucketEntryType type) { case LIVEENTRY: LedgerEntry liveEntry; case DEADENTRY: LedgerKey deadEntry; }; // Transaction sets are the unit used by SCP to decide on transitions // between ledgers const MAX_TX_PER_LEDGER = 5000; struct TransactionSet { Hash previousLedgerHash; TransactionEnvelope txs; }; struct TransactionResultPair { Hash transactionHash; TransactionResult result; // result for the transaction }; // TransactionResultSet is used to recover results between ledgers struct TransactionResultSet { TransactionResultPair results; }; // Entries below are used in the historical subsystem struct TransactionHistoryEntry { uint32 ledgerSeq; TransactionSet txSet; // reserved for future use union switch (int v) { case 0: void; } ext; }; struct TransactionHistoryResultEntry { uint32 ledgerSeq; TransactionResultSet txResultSet; // reserved for future use union switch (int v) { case 0: void; } ext; }; struct LedgerHeaderHistoryEntry { Hash hash; LedgerHeader header; // reserved for future use union switch (int v) { case 0: void; } ext; }; // represents the meta in the transaction table history enum LedgerEntryChangeType { LEDGER_ENTRY_CREATED = 0, // entry was added to the ledger LEDGER_ENTRY_UPDATED = 1, // entry was modified in the ledger LEDGER_ENTRY_REMOVED = 2 // entry was removed from the ledger }; union LedgerEntryChange switch (LedgerEntryChangeType type) { case LEDGER_ENTRY_CREATED: LedgerEntry created; case LEDGER_ENTRY_UPDATED: LedgerEntry updated; case LEDGER_ENTRY_REMOVED: LedgerKey removed; }; struct TransactionMeta { LedgerEntryChange changes<>; }; }