Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MD ¶
type MD struct { MD []*types.Hash // Array of hashes that represent the right edge of the Merkle tree HashList []types.Hash // List of Hashes in the order added to the chain }
MD Collects Hashes from some source, and allows the creation of MD Roots as desired.
func (*MD) AddToChain ¶
AddToChain Add a Hash to the chain and incrementally build the MD
func (*MD) GetHashList ¶
GetHashList Returns the list of Hashes to be stored in the Database so we can create the MD for this chain for this block. In Factom, this is much like a EntryBlock
func (*MD) GetMDRoot ¶
GetMDRoot Close off the Merkle Directed Acyclic Graph (Merkle DAG or MD) We take any trailing hashes in MD, hash them up and combine to create the Merkle Dag Root. Getting the closing ListMDRoot is non-destructive, which is useful for some use cases.
func (*MD) PrintMR ¶
PrintMR For debugging purposes, it is nice to get a string that shows the nil and non nil entries in c.MD Note that the "low order" entries are first in the string, so the binary is going from low order on the left to high order going right in the string rather than how binary is normally represented.
type MDNode ¶
type MDNode struct { Type uint8 // Type of data in this chain, drives validation SequenceNumber uint32 // sequence number of MDNodes in this chain Previous types.Hash // Hash of the previous MDNode in this chain; zeros if first block TotalEntries uint64 // Total number of entries at the start of this block in this chain MDSTate []types.Hash // Hashes in our intermediate state at the start of this block MDRoot types.Hash // MDRoot of all the data in this chain up to and not including this MDNode Hashes []types.Hash // Hashes in this block }
func (*MDNode) CompressState ¶
CompressState First check to make sure the current state matches the total number of entries at the start of this block.
type MDReceipt ¶
type MDReceipt struct { EntryHash types.Hash // Entry Hash of the data subject to the MDReceipt Nodes []*ReceiptNode // Path through the data collected by the MerkleDag MDRoot types.Hash // Merkle DAG root from the Accumulator network. }
func (*MDReceipt) BuildMDReceipt ¶
BuildMDReceipt Building a receipt is a bit more complex than just computing the Merkle DAG. We look at the stream of hashes as we build the MD, and detect when the Hash for which we need a receipt shows up. Then we track it through the intermediate hashes, tracking if it is combined from the right or from the left. Then when we have to calculate the Merkle DAG root, we do one more pass through the combining of the trailing hashes to finish off the receipt.