types

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

View Source
const (
	Version              = VersionField(0)          // Version of ValAcc
	NodeFirst            = "first node"             // Key: node.ChainID      Value:  First node hash with this chainID
	NodeNext             = "next node"              // Key: node.GetHash()    Value:  next node in sequence with this chainID
	NodeHead             = "node head"              // Key: node.ChainID      Value:  last node hash for this chainID
	Entry                = "entry"                  // Key: entry.GetHash()   Value:  Entry
	EntryNode            = "entry Node"             // Key: entry.GetHash()   Value:  node where this entry is recorded
	DirectoryBlockHeight = "directory block height" // Key: node.BHeight      Value:  Directory Block node
	Node                 = "node"                   // Key: node.GetHash()    Value:  nodeHash
)

======================= Database Support ======================================= Bucket Names used by the accumulator and validator

Variables

View Source
var StartApp time.Time

Functions

func BoolBytes

func BoolBytes(b bool) []byte

BoolBytes Marshal a Bool

func BytesBool

func BytesBool(data []byte) (f bool, newData []byte)

BytesBool Unmarshal a Uint8

func BytesUint16

func BytesUint16(data []byte) (uint16, []byte)

BytesUint16 Unmarshal a uint32 (big endian)

func BytesUint32

func BytesUint32(data []byte) (uint32, []byte)

BytesUint32 Unmarshal a uint32 (big endian)

func BytesUint64

func BytesUint64(data []byte) (uint64, []byte)

BytesUint64 Unmarshal a uint64 (big endian)

func DecodeVarInt

func DecodeVarInt(data []byte) (uint64, []byte)

DecodeVarInt decodes a variable integer from the given data buffer. We use the algorithm used by Go, only BigEndian.

func DecodeVarIntGo

func DecodeVarIntGo(data []byte) (uint64, []byte)

DecodeVarIntGo decodes a variable integer from the given data buffer. We use the algorithm used by Go, only BigEndian.

func EncodeVarInt

func EncodeVarInt(out *bytes.Buffer, v uint64) error

EncodeVarInt encodes an integer as a variable int into the given data buffer.

func EncodeVarIntGo

func EncodeVarIntGo(out *bytes.Buffer, v uint64) error

EncodeVarIntGo encodes an integer as a variable int into the given data buffer.

func EncodeVarIntGoBytes

func EncodeVarIntGoBytes(v uint64) (data []byte)

EncodeVarIntGoBytes Returns a byte slice that encodes the given integer.

func GetHomeDir

func GetHomeDir() string

GetHomeDir Used to find the Home Directory from which the configuration directory for the ValAcc application to use for its database. This is not a terribly refined way of configuring the ValAcc and may be refined in the future.

func Uint16Bytes

func Uint16Bytes(i uint16) []byte

Uint16Bytes Marshal a int32 (big endian)

func Uint32Bytes

func Uint32Bytes(i uint32) []byte

Uint32Bytes Marshal a int32 (big endian)

func Uint64Bytes

func Uint64Bytes(i uint64) []byte

Uint64Bytes Marshal a int64 (big endian)

func VarIntLength

func VarIntLength(v uint64) uint64

VarIntLength returns the length of the variable integer when encoded as a var int

Types

type Address

type Address [32]byte // An Address is the hash of a public key

Address ===========================================================================

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes Return a []byte for the Address

func (Address) Copy

func (a Address) Copy() *Address

Copy Return a copy of the hash

func (*Address) Extract

func (a *Address) Extract(data []byte) []byte

Extract Extract the address from the given byte slice

type BlockHeight

type BlockHeight uint32 // We are typing certain things in the protocol

func (BlockHeight) Bytes

func (bh BlockHeight) Bytes() []byte

func (*BlockHeight) Extract

func (bh *BlockHeight) Extract(data []byte) []byte

type DataField

type DataField []byte // Typing the Data Fields to allow flexibility in representation in the future

func (*DataField) Bytes

func (d *DataField) Bytes() []byte

func (*DataField) Copy

func (d *DataField) Copy() []byte

func (*DataField) Extract

func (d *DataField) Extract(len uint16, data []byte) []byte

type Hash

type Hash [32]byte // We are currently using sha256 hashes

Hash ===========================================================================

func GetChainID

func GetChainID(AccumulatorDID Hash, SubChainIDs []Hash) (chainID Hash)

GetChainID All the chainIDs under an Accumulator are unique to a DID in Factom, and unique from all chainIDs in other Accumulators and Factom itself.

A Factom ChainID is H( H(subChainID[0] + H(subChainID[1] + .. + H(subChainID[n]) where the ChainID has n subChainIDs.

An Accumulator ChainID is H (AccumulatorDID + 0x00 + H( H(subChainID[0] + H(subChainID[1] + .. + H(subChainID[n])) One cannot construct such a ChainID in Factom, nor on another AccumulatorDID.

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes Return a []byte for the Hash

func (Hash) Combine

func (h Hash) Combine(right Hash) *Hash

Combine Hash this hash (the left hash) with the given right hash to produce a new hash

func (Hash) Copy

func (h Hash) Copy() *Hash

Copy Return a copy of the hash

func (*Hash) Extract

func (h *Hash) Extract(data []byte) []byte

type PrivateKey

type PrivateKey [64]byte

Private Key ============================================================================

func (*PrivateKey) GetAddress

func (p *PrivateKey) GetAddress() [32]byte

GetAddress

func (*PrivateKey) GetPublicKey

func (p *PrivateKey) GetPublicKey() (publicKey []byte)

The public key is the last 32 bytes of the PrivateKey

func (*PrivateKey) Sign

func (p *PrivateKey) Sign(data []byte) []byte

Sign

func (*PrivateKey) Verify

func (p *PrivateKey) Verify(data []byte, signature []byte) bool

type Sequence

type Sequence uint32 // We are typing certain things in the protocol

func (Sequence) Bytes

func (s Sequence) Bytes() []byte

func (*Sequence) Extract

func (s *Sequence) Extract(data []byte) []byte

type Signature

type Signature struct {
	PublicKey []byte
	Signature [64]byte
}

Signature =============================================================================

func (Signature) Bytes

func (a Signature) Bytes() (b []byte)

Bytes Return a []byte for the Address

func (Signature) Copy

func (a Signature) Copy() *Signature

Copy Return a copy of the hash

func (*Signature) Extract

func (a *Signature) Extract(data []byte) []byte

Extract Extract the address from the given byte slice

type TimeStamp

type TimeStamp int64

func GetCurrentTimeStamp

func GetCurrentTimeStamp() TimeStamp

func (TimeStamp) Bytes

func (t TimeStamp) Bytes() []byte

func (*TimeStamp) Extract

func (t *TimeStamp) Extract(data []byte) (newData []byte)

Extract a timestamp from a byte slice. Return the updated byte slice.

type VersionField

type VersionField uint8 // We are typing certain things in the protocol

func (VersionField) Bytes

func (v VersionField) Bytes() []byte

func (*VersionField) Extract

func (v *VersionField) Extract(data []byte) []byte

Jump to

Keyboard shortcuts

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