node

package
v0.0.0-...-349195c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ANode

type ANode struct {
	Version     types.VersionField // Version of this data structure
	TimeStamp   types.TimeStamp    // Timestamp of the construction of this entry
	ChainID     types.Hash         // The ChainID
	SubChainIDs []types.Hash       // SubChainIDs required to build the ChainID
	ExtIDs      []types.DataField  // External ids used to create the chain id above ( see ExternalIDsToChainID() )
	Content     types.DataField    // BytesSlice for holding generic data for this entry
}

ANode Data is entered into system by the Accumulator as a series of entries organized by chainIDs Unlike Factom, we will attempt to create a chain if the ChainID provided is nil. We provide a function to compute the ChainID from the first entry in a chain, for use by applications. If a chain already exists, creating the chain will be ignored.

ANode

Version          uint8
TimeStamp        uint64
ChainID          [32]byte
len(SubChains)   uint64
SubChains        []SubChain
   Len(SubChain)    uint16
   SubChain[]       []byte
#ExtIDs          uint16
ExtIDs           []ExtID
  len(ExtID)        uint16
  ExtID             []byte
len(content)     uint16
Content          []byte

func (ANode) GetHash

func (e ANode) GetHash() (hash *types.Hash)

GetHash Returns the EntryHash for this entry. Note the ANode Hash does not include the SubChainIDs

func (ANode) Marshal

func (e ANode) Marshal() (bytes []byte)

Marshal Convert the given entry into a byte slice. Add to that the SubChainIDs of the ChainID. Returns nil if anything goes wrong while marshaling

func (ANode) SameAs

func (e ANode) SameAs(e2 ANode) bool

SameAs

func (*ANode) Unmarshal

func (e *ANode) Unmarshal(data []byte) (dataConsumed int, err error)

Unmarshal Extract an entry from a byte slice. Returns an error if the unmarshal fails, or the length of the data consumed and a nil.

type EntryHash

type EntryHash struct {
	SubChains []types.Hash // SubChainIDs used to create the ChainID
	ChainID   types.Hash   // The ChainID
	EntryHash types.Hash   // The EntryHash
}

EntryHash The accumulator assumes the ANode has already been written to the (a) database. It is only dealing with EntryHashes

type NEList

type NEList struct {
	ChainID types.Hash // ChainsInBlock or SubChain ID that leads to a node, or a ChainID that leads to an ANode
	MDRoot  types.Hash // Merkle Dag of either sub nodes or entries
}

NEList Node List (NEList) is a struct of a ChainID and a Node Hash

type Node

type Node struct {
	Version     types.VersionField // Version of this data structure
	BHeight     types.BlockHeight  // Block Height
	SequenceNum types.Sequence     // Sequence Number for this chain of nodes
	TimeStamp   types.TimeStamp    // TimeStamp by Accumulator when the structure was built
	ChainID     types.Hash         // The ChainID (Directory Block - zeros, SubNodes - 1st ChainID, Entries - ChainID)
	SubChainIDs []types.Hash       // SubChainIDs to build ChainID, Directory Block - zeros
	Previous    types.Hash         // Hash of previous Block Header
	IsNode      bool               // IsNode is true for a node, is false for an entry
	ListMDRoot  types.Hash         // Merkle DAG of the entries of the List (only the hashes)
	List        []NEList           // List of ChainIDs/MDRoots for Directory block or sub block nodes
	EntryList   []types.Hash       // List of Entry Hashes for an Entry node

	MarshalCache []byte // Cache of the marshaled form of the node.  Do NOT marshal a node unless

}

func (Node) GetHash

func (n Node) GetHash() (hash *types.Hash)

GetHash Return the hash for this sub node or entry node

func (Node) GetMDRoot

func (n Node) GetMDRoot() (mdRoot *types.Hash)

GetMDRoot The MDRoot is the combination of the header on the left, and the listMDRoot on the right. Returns a nil if the MDRoot doesn't exist do to missing data

func (Node) Marshal

func (n Node) Marshal() (bytes []byte)

Marshal Convert the given entry into a byte slice. Add to that the SubChainIDs of the ChainID. Returns nil if anything goes wrong while marshaling

func (Node) Put

func (n Node) Put(db *database.DB) error

Put Put this node into the database. There is a little special treatment for the Directory Blocks. In that case, the ChainID is the DID for the root Accumulator, and there are no SubChainIDs.

func (Node) SameAs

func (n Node) SameAs(n2 Node) bool

SameAs Compares two entries, mostly used for testing

func (*Node) Unmarshal

func (n *Node) Unmarshal(data []byte) (dataConsumed int, err error)

Unmarshal Extract an entry from a byte slice. Returns an error if the unmarshal fails, or the length of the data consumed and a nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL