jet

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package jet provides methods for working with Jet objects.

Index

Constants

This section is empty.

Variables

View Source
var ZeroJetID = *NewID(0, nil)

ZeroJetID is value of an empty Jet ID

Functions

func Encode

func Encode(drop *JetDrop) ([]byte, error)

Encode serializes jet drop.

func Jet

func Jet(id core.RecordID) (uint8, []byte)

Jet extracts depth and prefix from jet id.

func NewID

func NewID(depth uint8, prefix []byte) *core.RecordID

NewID generates RecordID for jet.

func Parent

func Parent(id core.RecordID) core.RecordID

func ResetBits

func ResetBits(value []byte, start uint8) []byte

ResetBits returns a new byte slice with all bits in 'value' reset, starting from 'start' number of bit. If 'start' is bigger than len(value), the original slice will be returned.

Types

type DropSize

type DropSize struct {
	JetID     core.RecordID
	PulseNo   core.PulseNumber
	DropSize  uint64
	Signature []byte
}

DropSize contains info about size of drop

func (*DropSize) WriteHashData

func (ds *DropSize) WriteHashData(w io.Writer) (int, error)

WriteHashData writes DropSize data to provided writer. This data is used to calculate DropSize's hash.

type DropSizeHistory

type DropSizeHistory []DropSize

DropSizeHistory is chain of drop sizes

func DeserializeJetDropSizeHistory

func DeserializeJetDropSizeHistory(ctx context.Context, buff []byte) (DropSizeHistory, error)

DeserializeJetDropSizeHistory deserializes DropSizeHistory

func (DropSizeHistory) Bytes

func (dropSizeHistory DropSizeHistory) Bytes() []byte

Bytes serializes DropSizeHistory

type IDSet

type IDSet map[core.RecordID]struct{}

IDSet is an alias for map[ID]struct{}

func (IDSet) Bytes

func (j IDSet) Bytes() []byte

Bytes serializes pulse.

func (IDSet) Has

func (j IDSet) Has(id core.RecordID) bool

Has checks if passed id is in IDSet set.

type JetDrop

type JetDrop struct {
	// Pulse number (probably we should save it too).
	Pulse core.PulseNumber

	// PrevHash is a hash of all record hashes belongs to previous pulse.
	PrevHash []byte

	// Hash is a hash of all record hashes belongs to one pulse and previous drop hash.
	Hash []byte
}

JetDrop is a blockchain block. It contains hashes of the current block and the previous one.

func Decode

func Decode(buf []byte) (*JetDrop, error)

Decode deserializes jet drop.

type Tree

type Tree struct {
	Head *jet
}

Tree stores jet in a binary tree.

func NewTree

func NewTree(isActual bool) *Tree

NewTree creates new tree.

func (*Tree) Bytes

func (t *Tree) Bytes() []byte

Bytes serializes pulse.

func (*Tree) Clone added in v0.8.0

func (t *Tree) Clone(keep bool) *Tree

Clone clones the tree keeping actuality or setting everything to false

func (*Tree) Find

func (t *Tree) Find(id core.RecordID) (*core.RecordID, bool)

Find returns jet for provided reference. If found jet is actual, the second argument will be true.

func (*Tree) LeafIDs

func (t *Tree) LeafIDs() []core.RecordID

func (*Tree) Merge

func (t *Tree) Merge(newTree *Tree) *Tree

Merge merges two trees to one

func (*Tree) Split

func (t *Tree) Split(jetID core.RecordID) (*core.RecordID, *core.RecordID, error)

Split looks for provided jet and creates (and returns) two branches for it. If provided jet is not found, an error will be returned.

func (Tree) String

func (t Tree) String() string

String visualizes Jet's tree.

func (*Tree) Update

func (t *Tree) Update(id core.RecordID, setActual bool)

Update add missing tree branches for provided prefix. If 'setActual' is set, all encountered nodes will be marked as actual.

Jump to

Keyboard shortcuts

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