entryBlock

package
v6.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeterministicEntry

func DeterministicEntry(i int) interfaces.IEBEntry

DeterministicEntry creates a new entry deterministically based on the input integer

func ExternalIDsToChainID

func ExternalIDsToChainID(extIDs [][]byte) interfaces.IHash

ExternalIDsToChainID converts the input external ids into a chain id. ChainID = primitives.Sha(Sha(ExtIDs[0]) + Sha(ExtIDs[1] + ... + Sha(ExtIDs[n]))

func MarshalEntryList

func MarshalEntryList(list []interfaces.IEBEntry) ([]byte, error)

MarshalEntryList marshals the input list into a single byte array

func NewChainID

func NewChainID(e interfaces.IEBEntry) interfaces.IHash

NewChainID generates a ChainID from an entry. ChainID = primitives.Sha(Sha(ExtIDs[0]) + Sha(ExtIDs[1] + ... + Sha(ExtIDs[n]))

func RandomEntry

func RandomEntry() interfaces.IEBEntry

RandomEntry produces an entry object with randomly initialized values

func UnmarshalEBlock

func UnmarshalEBlock(data []byte) (interfaces.IEntryBlock, error)

UnmarshalEBlock unmarshals the input data into a new entry block

func UnmarshalEBlockData

func UnmarshalEBlockData(data []byte) (interfaces.IEntryBlock, []byte, error)

UnmarshalEBlockData unmarshals the input data into a new entry block

func UnmarshalEntry

func UnmarshalEntry(data []byte) (interfaces.IEBEntry, error)

UnmarshalEntry unmarshals the input data into a new entry

func UnmarshalEntryList

func UnmarshalEntryList(data []byte) ([]interfaces.IEBEntry, []byte, error)

UnmarshalEntryList unmarshals the input byte array into a list of entries

Types

type EBlock

type EBlock struct {
	Header interfaces.IEntryBlockHeader `json:"header"` // Header of the Eblock
	Body   *EBlockBody                  `json:"body"`   // Array of entries from a single chain id associated with this entry block
}

EBlock is the Entry Block. It holds the hashes of the Entries and its Merkle Root is written into the Directory Blocks. Each Entry Block represents all of the entries for a particular Chain during a 10 minute period (a single directory block's worth of time)

func NewEBlock

func NewEBlock() *EBlock

NewEBlock returns a blank initialized Entry Block with all fields zeroed.

func (*EBlock) AddEBEntry

func (e *EBlock) AddEBEntry(entry interfaces.IEBEntry) error

AddEBEntry creates a new Entry Block Entry from the provided Factom Entry and adds it to the Entry Block Body.

func (*EBlock) AddEndOfMinuteMarker

func (e *EBlock) AddEndOfMinuteMarker(m byte) error

AddEndOfMinuteMarker adds the End of Minute to the Entry Block. The End of Minute byte becomes the last byte in a 32 byte slice that is added to the Entry Block Body as an Entry Block Entry.

func (*EBlock) BodyKeyMR

func (e *EBlock) BodyKeyMR() (rval interfaces.IHash)

BodyKeyMR updates the entry header with its current state, and then returns the body Merkle root

func (*EBlock) BuildHeader

func (e *EBlock) BuildHeader() error

BuildHeader updates the Entry Block Header to include information about the Entry Block Body. BuildHeader should be run after the Entry Block Body has included all of its EntryEntries.

func (*EBlock) DatabasePrimaryIndex

func (e *EBlock) DatabasePrimaryIndex() (rval interfaces.IHash)

DatabasePrimaryIndex returns the key Merkle root of the entry block

func (*EBlock) DatabaseSecondaryIndex

func (e *EBlock) DatabaseSecondaryIndex() (rval interfaces.IHash)

DatabaseSecondaryIndex returns the single sha of the marshalled object

func (*EBlock) GetBody

func (e *EBlock) GetBody() interfaces.IEBlockBody

GetBody returns the body of the entry block

func (*EBlock) GetChainID

func (e *EBlock) GetChainID() (rval interfaces.IHash)

GetChainID returns the chain id associated with this entry block

func (*EBlock) GetDatabaseHeight

func (e *EBlock) GetDatabaseHeight() uint32

GetDatabaseHeight returns the directory block height

func (*EBlock) GetEntryHashes

func (e *EBlock) GetEntryHashes() []interfaces.IHash

GetEntryHashes returns the cumulative entries into a single chain for this 10 minute block

func (*EBlock) GetEntrySigHashes

func (e *EBlock) GetEntrySigHashes() []interfaces.IHash

GetEntrySigHashes always returns nil

func (*EBlock) GetHash

func (e *EBlock) GetHash() (rval interfaces.IHash)

GetHash returns the single sha of the marshalled object

func (*EBlock) GetHashOfChainID

func (e *EBlock) GetHashOfChainID() []byte

GetHashOfChainID returns the double sha of the chain id

func (*EBlock) GetHashOfChainIDHash

func (e *EBlock) GetHashOfChainIDHash() (rval interfaces.IHash)

GetHashOfChainIDHash returns the double sha of the chain id

func (*EBlock) GetHeader

func (e *EBlock) GetHeader() interfaces.IEntryBlockHeader

GetHeader returns the header of the entry block

func (*EBlock) Hash

func (e *EBlock) Hash() (interfaces.IHash, error)

Hash returns the simple Sha256 hash of the serialized Entry Block. Hash is used to provide the PrevFullHash to the next Entry Block in a Chain.

func (*EBlock) HeaderHash

func (e *EBlock) HeaderHash() (interfaces.IHash, error)

HeaderHash returns the single sha of the marshalled header object

func (*EBlock) Init

func (e *EBlock) Init()

Init initializes any nil members of the entry block

func (*EBlock) IsSameAs

func (e *EBlock) IsSameAs(b interfaces.IEntryBlock) bool

IsSameAs returns true iff the two entry blocks are identical

func (*EBlock) JSONByte

func (e *EBlock) JSONByte() ([]byte, error)

JSONByte returns the json encoded byte array

func (*EBlock) JSONString

func (e *EBlock) JSONString() (string, error)

JSONString returns the json encoded string

func (*EBlock) KeyMR

func (e *EBlock) KeyMR() (interfaces.IHash, error)

KeyMR returns the hash of two items: 1) the hash of the Entry Block Header concatenated with 2) the Merkle Root of the Entry Block Body. The Body Merkle Root is calculated by the func (e *EBlockBody) MR() which is called by the func (e *EBlock) BuildHeader().

func (*EBlock) MarshalBinary

func (e *EBlock) MarshalBinary() (rval []byte, err error)

MarshalBinary returns the serialized binary form of the Entry Block.

func (*EBlock) New

New returns a new entry block

func (*EBlock) String

func (e *EBlock) String() string

String returns the object as a string

func (*EBlock) UnmarshalBinary

func (e *EBlock) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary populates the Entry Block object from the serialized binary data.

func (*EBlock) UnmarshalBinaryData

func (e *EBlock) UnmarshalBinaryData(data []byte) (newData []byte, err error)

UnmarshalBinaryData populates the Entry Block object from the serialized binary data.

type EBlockBody

type EBlockBody struct {
	EBEntries []interfaces.IHash `json:"ebentries"` // Array of entries from a single chain id associated with this entry block
}

EBlockBody is the series of Hashes that form the Entry Block Body.

func NewEBlockBody

func NewEBlockBody() *EBlockBody

NewEBlockBody initializes an empty Entry Block Body.

func (*EBlockBody) AddEBEntry

func (e *EBlockBody) AddEBEntry(entry interfaces.IHash)

AddEBEntry creates a new Entry Block Entry from the provided Factom Entry and adds it to the Entry Block Body.

func (*EBlockBody) AddEndOfMinuteMarker

func (e *EBlockBody) AddEndOfMinuteMarker(m byte)

AddEndOfMinuteMarker adds the End of Minute to the Entry Block. The End of Minut byte becomes the last byte in a 32 byte slice that is added to the Entry Block Body as an Entry Block Entry.

func (*EBlockBody) GetEBEntries

func (e *EBlockBody) GetEBEntries() []interfaces.IHash

GetEBEntries returns the hash array associated with the entry block

func (*EBlockBody) IsSameAs

func (e *EBlockBody) IsSameAs(b interfaces.IEBlockBody) bool

IsSameAs returns true iff th einput object is the same as this object

func (*EBlockBody) JSONByte

func (e *EBlockBody) JSONByte() ([]byte, error)

JSONByte returns the json encoded byte array

func (*EBlockBody) JSONString

func (e *EBlockBody) JSONString() (string, error)

JSONString returns the json encoded byte string

func (*EBlockBody) MR

func (e *EBlockBody) MR() (rval interfaces.IHash)

MR calculates the Merkle Root of the Entry Block Body. See func primitives.BuildMerkleTreeStore(hashes []interfaces.IHash) (merkles []interfaces.IHash) in common/merkle.go.

func (*EBlockBody) String

func (e *EBlockBody) String() string

String returns this object as a string

type EBlockHeader

type EBlockHeader struct {
	ChainID      interfaces.IHash `json:"chainid"`      // The chain id associated with this entry block's entries (hash array)
	BodyMR       interfaces.IHash `json:"bodymr"`       // The Merkle root of the Entry block's entries (hash array)
	PrevKeyMR    interfaces.IHash `json:"prevkeymr"`    // The Merkle root of the previous entry block for this chain id
	PrevFullHash interfaces.IHash `json:"prevfullhash"` // The full hash of the previous entry block for this chain id
	EBSequence   uint32           `json:"ebsequence"`   // Entry block sequence number: ie 7 = the seventh entry block for this chain id
	DBHeight     uint32           `json:"dbheight"`     // The directory block height this entry block is located in
	EntryCount   uint32           `json:"entrycount"`   // How many entries are in the hash array for this entry block
}

EBlockHeader holds relevant metadata about the Entry Block and the data necessary to verify the previous block in the Entry Block Chain.

func NewEBlockHeader

func NewEBlockHeader() *EBlockHeader

NewEBlockHeader initializes a new empty Entry Block Header.

func (*EBlockHeader) GetBodyMR

func (e *EBlockHeader) GetBodyMR() (rval interfaces.IHash)

GetBodyMR returns the Merkle root of the entry blocks body (the hash array)

func (*EBlockHeader) GetChainID

func (e *EBlockHeader) GetChainID() (rval interfaces.IHash)

GetChainID returns the chain id of this entry block

func (*EBlockHeader) GetDBHeight

func (e *EBlockHeader) GetDBHeight() uint32

GetDBHeight returns the directory block height this entry block is from

func (*EBlockHeader) GetEBSequence

func (e *EBlockHeader) GetEBSequence() uint32

GetEBSequence returns this entry block's sequence number

func (*EBlockHeader) GetEntryCount

func (e *EBlockHeader) GetEntryCount() uint32

GetEntryCount returns the number of entries in this entry block

func (*EBlockHeader) GetPrevFullHash

func (e *EBlockHeader) GetPrevFullHash() (rval interfaces.IHash)

GetPrevFullHash returns the previous entry blocks full hash associated with this chain id

func (*EBlockHeader) GetPrevKeyMR

func (e *EBlockHeader) GetPrevKeyMR() (rval interfaces.IHash)

GetPrevKeyMR return the previous entry blocks Merkle root

func (*EBlockHeader) Init

func (e *EBlockHeader) Init()

Init initializes the objects hashes to the zero hash if they are nil

func (*EBlockHeader) IsSameAs

IsSameAs returns true iff the input object is the same as this object

func (*EBlockHeader) JSONByte

func (e *EBlockHeader) JSONByte() ([]byte, error)

JSONByte returns the json encoded byte array

func (*EBlockHeader) JSONString

func (e *EBlockHeader) JSONString() (string, error)

JSONString returns the json encoded string

func (*EBlockHeader) MarshalBinary

func (e *EBlockHeader) MarshalBinary() (rval []byte, err error)

MarshalBinary returns a serialized binary Entry Block Header

func (*EBlockHeader) SetBodyMR

func (e *EBlockHeader) SetBodyMR(bodyMR interfaces.IHash)

SetBodyMR sets the body Merkle root to th einput value

func (*EBlockHeader) SetChainID

func (e *EBlockHeader) SetChainID(chainID interfaces.IHash)

SetChainID sets the chain id associated with this entry block's entries

func (*EBlockHeader) SetDBHeight

func (e *EBlockHeader) SetDBHeight(dbHeight uint32)

SetDBHeight sets the directory block height this entry block is from

func (*EBlockHeader) SetEBSequence

func (e *EBlockHeader) SetEBSequence(sequence uint32)

SetEBSequence sets this entry block's sequence number

func (*EBlockHeader) SetEntryCount

func (e *EBlockHeader) SetEntryCount(entryCount uint32)

SetEntryCount sets the number of entries in this entry block

func (*EBlockHeader) SetPrevFullHash

func (e *EBlockHeader) SetPrevFullHash(prevFullHash interfaces.IHash)

SetPrevFullHash sets the previous entry blocks full hash associated with this chain id

func (*EBlockHeader) SetPrevKeyMR

func (e *EBlockHeader) SetPrevKeyMR(prevKeyMR interfaces.IHash)

SetPrevKeyMR sets the previous entry block key Merkle root to the input value

func (*EBlockHeader) String

func (e *EBlockHeader) String() string

String returns this object as a string

func (*EBlockHeader) UnmarshalBinary

func (e *EBlockHeader) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary builds the Entry Block Header from the serialized binary.

func (*EBlockHeader) UnmarshalBinaryData

func (e *EBlockHeader) UnmarshalBinaryData(data []byte) ([]byte, error)

UnmarshalBinaryData builds the Entry Block Header from the serialized binary.

type Entry

type Entry struct {
	Version uint8                  `json:"version"` // The entry version, only currently supported number is 0
	ChainID interfaces.IHash       `json:"chainid"` // The chain id associated with this entry
	ExtIDs  []primitives.ByteSlice `json:"extids"`  // External ids used to create the chain id above ( see ExternalIDsToChainID() )
	Content primitives.ByteSlice   `json:"content"` // BytesSlice for holding generic data for this entry
	// contains filtered or unexported fields
}

An Entry is the element which carries user data to be stored in the blockchain https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#entry

func NewEntry

func NewEntry() *Entry

NewEntry returns a new entry initialized with empty interfaces and zero hashes

func (*Entry) DatabasePrimaryIndex

func (c *Entry) DatabasePrimaryIndex() (rval interfaces.IHash)

DatabasePrimaryIndex returns the hash of the entry object

func (*Entry) DatabaseSecondaryIndex

func (c *Entry) DatabaseSecondaryIndex() (rval interfaces.IHash)

DatabaseSecondaryIndex always returns nil (ie, no secondary index)

func (*Entry) ExternalIDs

func (c *Entry) ExternalIDs() [][]byte

ExternalIDs returns an array of the external ids

func (*Entry) GetChainID

func (c *Entry) GetChainID() (rval interfaces.IHash)

GetChainID returns the chain id of this entry

func (*Entry) GetChainIDHash

func (c *Entry) GetChainIDHash() (rval interfaces.IHash)

GetChainIDHash returns the chain id associated with this entry

func (*Entry) GetContent

func (c *Entry) GetContent() []byte

GetContent returns the content

func (*Entry) GetDatabaseHeight

func (c *Entry) GetDatabaseHeight() uint32

GetDatabaseHeight always returns 0

func (*Entry) GetHash

func (c *Entry) GetHash() (rval interfaces.IHash)

GetHash returns the hash of the entry: sha256(append(sha512(data),data))

func (*Entry) GetWeld

func (c *Entry) GetWeld() []byte

GetWeld returns the double sha of the entry's hash and chain id appended ('welded') together

func (*Entry) GetWeldHash

func (c *Entry) GetWeldHash() (rval interfaces.IHash)

GetWeldHash returns the doble sha of the entry's hash and chain id appended ('welded') together

func (*Entry) IsSameAs

func (c *Entry) IsSameAs(b interfaces.IEBEntry) bool

IsSameAs returns true iff the input entry is identical to this entry

func (*Entry) IsValid

func (c *Entry) IsValid() bool

IsValid checks whether an entry is considered valid. A valid entry must satisfy both conditions: 1) have version==0 AND 2) KSize() <= 10

func (*Entry) JSONByte

func (c *Entry) JSONByte() ([]byte, error)

JSONByte returns the json encoded byte array

func (*Entry) JSONString

func (c *Entry) JSONString() (string, error)

JSONString returns the json encoded string

func (*Entry) KSize

func (c *Entry) KSize() int

KSize returns the size of the entry subject to payment in K. So anything up to 1K returns 1, everything up to and including 2K returns 2, etc. An error returns 100 (an invalid size)

func (*Entry) MarshalBinary

func (c *Entry) MarshalBinary() (rval []byte, err error)

MarshalBinary marshals the object

func (*Entry) MarshalExtIDsBinary

func (c *Entry) MarshalExtIDsBinary() (rval []byte, err error)

MarshalExtIDsBinary marshals the ExtIDs into a []byte containing a series of 2 byte size of each ExtID followed by the ExtID.

func (*Entry) New

New creates a new entry

func (*Entry) String

func (c *Entry) String() string

String returns this object as a string

func (*Entry) UnmarshalBinary

func (c *Entry) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary unmarshals the input data into this object

func (*Entry) UnmarshalBinaryData

func (c *Entry) UnmarshalBinaryData(data []byte) (_ []byte, err error)

UnmarshalBinaryData unmarshals the input data into this object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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