entryBlock

package
v6.2.2-rc3+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExternalIDsToChainID

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

func MarshalEntryList

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

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

func UnmarshalEBlock

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

func UnmarshalEBlockData

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

func UnmarshalEntry

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

func UnmarshalEntryList

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

Types

type EBlock

type EBlock struct {
	Header interfaces.IEntryBlockHeader `json:"header"`
	Body   *EBlockBody                  `json:"body"`
}

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.

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 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 (*EBlock) BodyKeyMR

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

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 (c *EBlock) DatabasePrimaryIndex() (rval interfaces.IHash)

func (*EBlock) DatabaseSecondaryIndex

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

func (*EBlock) GetBody

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

func (*EBlock) GetChainID

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

func (*EBlock) GetDatabaseHeight

func (c *EBlock) GetDatabaseHeight() uint32

func (*EBlock) GetEntryHashes

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

func (*EBlock) GetEntrySigHashes

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

func (*EBlock) GetHash

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

func (*EBlock) GetHashOfChainID

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

func (*EBlock) GetHashOfChainIDHash

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

func (*EBlock) GetHeader

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

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)

func (*EBlock) Init

func (c *EBlock) Init()

func (*EBlock) IsSameAs

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

func (*EBlock) JSONByte

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

func (*EBlock) JSONString

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

func (*EBlock) KeyMR

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

KeyMR returns the hash of the hash of the Entry Block Header concatenated with 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

func (*EBlock) String

func (e *EBlock) String() string

func (*EBlock) UnmarshalBinary

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

func (*EBlock) UnmarshalBinaryData

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

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

type EBlockBody

type EBlockBody struct {
	EBEntries []interfaces.IHash `json:"ebentries"`
}

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

func (*EBlockBody) IsSameAs

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

func (*EBlockBody) JSONByte

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

func (*EBlockBody) JSONString

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

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

type EBlockHeader

type EBlockHeader struct {
	ChainID      interfaces.IHash `json:"chainid"`
	BodyMR       interfaces.IHash `json:"bodymr"`
	PrevKeyMR    interfaces.IHash `json:"prevkeymr"`
	PrevFullHash interfaces.IHash `json:"prevfullhash"`
	EBSequence   uint32           `json:"ebsequence"`
	DBHeight     uint32           `json:"dbheight"`
	EntryCount   uint32           `json:"entrycount"`
}

EBlockHeader holds relevant metadata about the Entry Block and the data nessisary 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 (c *EBlockHeader) GetBodyMR() (rval interfaces.IHash)

func (*EBlockHeader) GetChainID

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

func (*EBlockHeader) GetDBHeight

func (c *EBlockHeader) GetDBHeight() uint32

func (*EBlockHeader) GetEBSequence

func (c *EBlockHeader) GetEBSequence() uint32

func (*EBlockHeader) GetEntryCount

func (c *EBlockHeader) GetEntryCount() uint32

func (*EBlockHeader) GetPrevFullHash

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

func (*EBlockHeader) GetPrevKeyMR

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

func (*EBlockHeader) Init

func (e *EBlockHeader) Init()

func (*EBlockHeader) IsSameAs

func (*EBlockHeader) JSONByte

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

func (*EBlockHeader) JSONString

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

func (*EBlockHeader) MarshalBinary

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

marshalHeaderBinary returns a serialized binary Entry Block Header

func (*EBlockHeader) SetBodyMR

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

func (*EBlockHeader) SetChainID

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

func (*EBlockHeader) SetDBHeight

func (c *EBlockHeader) SetDBHeight(dbHeight uint32)

func (*EBlockHeader) SetEBSequence

func (c *EBlockHeader) SetEBSequence(sequence uint32)

func (*EBlockHeader) SetEntryCount

func (c *EBlockHeader) SetEntryCount(entryCount uint32)

func (*EBlockHeader) SetPrevFullHash

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

func (*EBlockHeader) SetPrevKeyMR

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

func (*EBlockHeader) String

func (e *EBlockHeader) String() string

func (*EBlockHeader) UnmarshalBinary

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

func (*EBlockHeader) UnmarshalBinaryData

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

unmarshalHeaderBinary builds the Entry Block Header from the serialized binary.

type Entry

type Entry struct {
	Version uint8                  `json:"version"`
	ChainID interfaces.IHash       `json:"chainid"`
	ExtIDs  []primitives.ByteSlice `json:"extids"`
	Content primitives.ByteSlice   `json:"content"`
	// contains filtered or unexported fields
}

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

func NewEntry

func NewEntry() *Entry

func (*Entry) DatabasePrimaryIndex

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

func (*Entry) DatabaseSecondaryIndex

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

func (*Entry) ExternalIDs

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

func (*Entry) GetChainID

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

func (*Entry) GetChainIDHash

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

func (*Entry) GetContent

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

func (*Entry) GetDatabaseHeight

func (c *Entry) GetDatabaseHeight() uint32

func (*Entry) GetHash

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

func (*Entry) GetWeld

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

func (*Entry) GetWeldHash

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

func (*Entry) IsSameAs

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

func (*Entry) IsValid

func (e *Entry) IsValid() bool

func (*Entry) JSONByte

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

func (*Entry) JSONString

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

func (*Entry) KSize

func (c *Entry) KSize() int

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 (e *Entry) MarshalBinary() (rval []byte, err error)

func (*Entry) MarshalExtIDsBinary

func (e *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

func (*Entry) String

func (e *Entry) String() string

func (*Entry) UnmarshalBinary

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

func (*Entry) UnmarshalBinaryData

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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