pstore2
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
pstore::trailer Struct Reference

The transaction footer structure. More...

#include <file_header.hpp>

Collaboration diagram for pstore::trailer:
Collaboration graph
[legend]

Classes

struct  body
 Represents the portion of the trailer structure which is covered by the computed CRC value. More...
 

Public Types

enum  indices : unsigned { last }
 
using index_records_array = std::array< typed_address< index::header_block >, static_cast< std::underlying_type< indices >::type >(indices::last)>
 

Public Member Functions

bool crc_is_valid () const noexcept
 
bool signature_is_valid () const noexcept
 
std::uint32_t get_crc () const noexcept
 Computes the trailer's CRC value.
 

Static Public Member Functions

static bool validate (database const &db, typed_address< trailer > pos)
 Checks that the address given by 'pos' appears to point to a valid transaction trailer. More...
 

Public Attributes

body a
 
std::uint32_t crc = 0
 The fields of a transaction footer are not modified as the code interacts with the data store. More...
 
std::uint32_t unused1 = 0
 
std::array< std::uint8_t, 8 > signature2 = default_signature2
 

Static Public Attributes

static std::array< std::uint8_t, 8 > const default_signature1
 
static std::array< std::uint8_t, 8 > const default_signature2
 

Detailed Description

The transaction footer structure.

An copy of this structure is written to the data store at the end of each transaction block. pstore::header::footer_pos holds the address of the latest complete instance and is updated once a transaction has been completely written to memory. Once written it is read-only.

Member Function Documentation

◆ validate()

bool pstore::trailer::validate ( database const &  db,
typed_address< trailer pos 
)
static

Checks that the address given by 'pos' appears to point to a valid transaction trailer.

Raises exception::footer_corrupt if not.

Member Data Documentation

◆ crc

std::uint32_t pstore::trailer::crc = 0

The fields of a transaction footer are not modified as the code interacts with the data store.

The memory that is occupies as marked as read-only as soon as the host OS and hardware permits. Despite this guarantee it's useful to be able to ensure that the reverse-order linked list of transactions – whose head is given by header::footer_pos is intact and that we don't have a stray pointer.

◆ default_signature1

std::array< std::uint8_t, 8 > const pstore::trailer::default_signature1
static
Initial value:
{
{'h', 'P', 'P', 'y', 'f', 'o', 'o', 'T'}}

◆ default_signature2

std::array< std::uint8_t, 8 > const pstore::trailer::default_signature2
static
Initial value:
{
{'h', 'P', 'P', 'y', 'T', 'a', 'i', 'l'}}

The documentation for this struct was generated from the following files: