lazyledger

package module
v0.0.0-...-2aeca6f Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MIT Imports: 14 Imported by: 5

README

lazyledger-prototype

Build Status Coverage Status GoDoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFlagHasher

func NewFlagHasher(flagger Flagger, baseHasher hash.Hash) hash.Hash

NewFlagHasher returns a new hash.Hash computing checksums using the bashHasher with flags from flagger.

Types

type AddPetitionMessage

type AddPetitionMessage struct {
	Text                 *string  `protobuf:"bytes,1,req,name=text" json:"text,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*AddPetitionMessage) Descriptor

func (*AddPetitionMessage) Descriptor() ([]byte, []int)

func (*AddPetitionMessage) GetText

func (m *AddPetitionMessage) GetText() string

func (*AddPetitionMessage) ProtoMessage

func (*AddPetitionMessage) ProtoMessage()

func (*AddPetitionMessage) Reset

func (m *AddPetitionMessage) Reset()

func (*AddPetitionMessage) String

func (m *AddPetitionMessage) String() string

func (*AddPetitionMessage) XXX_DiscardUnknown

func (m *AddPetitionMessage) XXX_DiscardUnknown()

func (*AddPetitionMessage) XXX_Marshal

func (m *AddPetitionMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AddPetitionMessage) XXX_Merge

func (m *AddPetitionMessage) XXX_Merge(src proto.Message)

func (*AddPetitionMessage) XXX_Size

func (m *AddPetitionMessage) XXX_Size() int

func (*AddPetitionMessage) XXX_Unmarshal

func (m *AddPetitionMessage) XXX_Unmarshal(b []byte) error

type Application

type Application interface {
	// ProcessMessage processes a message according to the application's state machine.
	ProcessMessage(message Message)

	// Namespace returns the namespace ID of the application.
	Namespace() [namespaceSize]byte

	// BlockHead returns the hash of the latest block that has been processed.
	BlockHead() []byte

	// SetBlockHead sets the hash of the latest block that has been processed.
	SetBlockHead(hash []byte)
}

Application is an interface for a lazyledger application.

func NewCurrency

func NewCurrency(state MapStore, b *Blockchain) Application

NewCurrency creates a new currency instance.

func NewDummyApp

func NewDummyApp(state MapStore) Application

func NewPetitionApp

func NewPetitionApp(state MapStore) Application

func NewRegistrar

func NewRegistrar(state MapStore, currency *Currency, owner []byte) Application

type Block

type Block interface {
	// AddMessage adds a message to the block.
	AddMessage(Message)

	// Digest computes the hash of the block.
	Digest() []byte

	// Valid returns true if the block is valid.
	Valid() bool

	// PrevHash returns the hash of the previous block.
	PrevHash() []byte

	// Messages returns the block's messages.
	Messages() []Message

	ProveDependency(int) ([]byte, [][]byte, error)

	VerifyDependency(int, []byte, [][]byte) bool

	DependencyProven([]byte) bool
}

Block represents a block in the chain.

func ImportProbabilisticBlock

func ImportProbabilisticBlock(prevHash []byte, messages []Message, messageSize int, validated bool) Block

ImportProbabilisticBlock imports a received probabilistic block.

func ImportProbabilisticBlockHeader

func ImportProbabilisticBlockHeader(prevHash []byte, rowRoots [][]byte, columnRoots [][]byte, squareWidth int, messageSize int, validated bool) Block

ImportProbabilisticBlockBlockHeader imports a received probabilistic block without the messages.

func ImportSimpleBlock

func ImportSimpleBlock(prevHash []byte, messages []Message) Block

ImportSimpleBlock imports a received simple block.

func ImportSimpleBlockHeader

func ImportSimpleBlockHeader(prevHash []byte, messagesRoot []byte) Block

ImportSimpleBlockHeader imports a received simple block without the messages.

func NewProbabilisticBlock

func NewProbabilisticBlock(prevHash []byte, messageSize int) Block

NewProbabilisticBlock returns a new probabilistic block.

func NewSimpleBlock

func NewSimpleBlock(prevHash []byte) Block

NewSimpleBlock returns a new simple block.

type BlockStore

type BlockStore interface {
	Get(key []byte) (Block, error)     // Get gets the value for a key.
	Put(key []byte, value Block) error // Put updates the value for a key.
	Del(key []byte) error              // Del deletes a key.
}

BlockStore is a key-value store for blocks.

type Blockchain

type Blockchain struct {
	// contains filtered or unexported fields
}

Blockchain is a chain of blocks. This is a prototype for testing purposes and thus does not support re-orgs, and there is no network stack.

func NewBlockchain

func NewBlockchain(blockStore BlockStore) *Blockchain

NewBlockchain returns a new blockchain.

func (*Blockchain) Block

func (b *Blockchain) Block(digest []byte) (Block, error)

func (*Blockchain) ProcessBlock

func (b *Blockchain) ProcessBlock(block Block)

ProcessBlock processes a new block.

func (*Blockchain) RegisterApplication

func (b *Blockchain) RegisterApplication(application *Application)

RegisterApplication registers an application instance to call when new relevant messages arrive.

type BytesLeafHasher

type BytesLeafHasher struct {
	// contains filtered or unexported fields
}

BytesLeafHasher implements the merkletree.LeafHasher interface by reading a slice.

func NewBytesLeafHasher

func NewBytesLeafHasher(data [][]byte, h hash.Hash) *BytesLeafHasher

NewBytesLeafHasher returns a new BytesLeafHasher for a slice.

func (*BytesLeafHasher) NextLeafHash

func (blh *BytesLeafHasher) NextLeafHash() (leafHash []byte, err error)

NextLeafHash implements LeafHasher

type CodedAxisSubtreeHasher

type CodedAxisSubtreeHasher struct {
	// contains filtered or unexported fields
}

CodedAxisSubtreeHasher implements merkletree.SubtreeHasher by reading leaf data from an underlying slice representing a coded axis.

func NewCodedAxisSubtreeHasher

func NewCodedAxisSubtreeHasher(data [][]byte, h hash.Hash) *CodedAxisSubtreeHasher

NewCodedAxisSubtreeHasher returns a new CodedAxisSubtreeHasher for a pointer to a slice representing a coded axis.

func (*CodedAxisSubtreeHasher) NextSubtreeRoot

func (cash *CodedAxisSubtreeHasher) NextSubtreeRoot(subtreeSize int) ([]byte, error)

NextSubtreeRoot implements SubtreeHasher.

func (*CodedAxisSubtreeHasher) Skip

func (cash *CodedAxisSubtreeHasher) Skip(n int) error

Skip implements SubtreeHasher.

type Currency

type Currency struct {
	// contains filtered or unexported fields
}

Currency is a demo cryptocurrency application.

func (*Currency) AddTransferCallback

func (c *Currency) AddTransferCallback(fn TransferCallback)

func (*Currency) Balance

func (c *Currency) Balance(pubKey crypto.PubKey) uint64

Balance gets the balance of a public key.

func (*Currency) BlockHead

func (c *Currency) BlockHead() []byte

BlockHead returns the hash of the latest block that has been processed.

func (*Currency) GenerateTransaction

func (c *Currency) GenerateTransaction(fromPrivKey crypto.PrivKey, toPubKey crypto.PubKey, amount uint64, dependency []byte) Message

GenerateTransaction generates a transaction message.

func (*Currency) Namespace

func (c *Currency) Namespace() [namespaceSize]byte

Namespace returns the application's namespace ID.

func (*Currency) ProcessMessage

func (c *Currency) ProcessMessage(message Message)

ProcessMessage processes a message.

func (*Currency) SetBlockHead

func (c *Currency) SetBlockHead(hash []byte)

SetBlockHead sets the hash of the latest block that has been processed.

func (*Currency) StorageSize

func (c *Currency) StorageSize() int

type CurrencyTransaction

type CurrencyTransaction struct {
	To                   []byte   `protobuf:"bytes,1,req,name=to" json:"to,omitempty"`
	From                 []byte   `protobuf:"bytes,2,req,name=from" json:"from,omitempty"`
	Amount               *uint64  `protobuf:"varint,3,req,name=amount" json:"amount,omitempty"`
	Signature            []byte   `protobuf:"bytes,4,req,name=signature" json:"signature,omitempty"`
	Dependency           []byte   `protobuf:"bytes,5,opt,name=dependency" json:"dependency,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*CurrencyTransaction) Descriptor

func (*CurrencyTransaction) Descriptor() ([]byte, []int)

func (*CurrencyTransaction) GetAmount

func (m *CurrencyTransaction) GetAmount() uint64

func (*CurrencyTransaction) GetDependency

func (m *CurrencyTransaction) GetDependency() []byte

func (*CurrencyTransaction) GetFrom

func (m *CurrencyTransaction) GetFrom() []byte

func (*CurrencyTransaction) GetSignature

func (m *CurrencyTransaction) GetSignature() []byte

func (*CurrencyTransaction) GetTo

func (m *CurrencyTransaction) GetTo() []byte

func (*CurrencyTransaction) ProtoMessage

func (*CurrencyTransaction) ProtoMessage()

func (*CurrencyTransaction) Reset

func (m *CurrencyTransaction) Reset()

func (*CurrencyTransaction) String

func (m *CurrencyTransaction) String() string

func (*CurrencyTransaction) XXX_DiscardUnknown

func (m *CurrencyTransaction) XXX_DiscardUnknown()

func (*CurrencyTransaction) XXX_Marshal

func (m *CurrencyTransaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CurrencyTransaction) XXX_Merge

func (m *CurrencyTransaction) XXX_Merge(src proto.Message)

func (*CurrencyTransaction) XXX_Size

func (m *CurrencyTransaction) XXX_Size() int

func (*CurrencyTransaction) XXX_Unmarshal

func (m *CurrencyTransaction) XXX_Unmarshal(b []byte) error

type CurrencyTransactionMessage

type CurrencyTransactionMessage struct {
	To                   []byte   `protobuf:"bytes,1,req,name=to" json:"to,omitempty"`
	Amount               *uint64  `protobuf:"varint,2,req,name=amount" json:"amount,omitempty"`
	Dependency           []byte   `protobuf:"bytes,3,opt,name=dependency" json:"dependency,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*CurrencyTransactionMessage) Descriptor

func (*CurrencyTransactionMessage) Descriptor() ([]byte, []int)

func (*CurrencyTransactionMessage) GetAmount

func (m *CurrencyTransactionMessage) GetAmount() uint64

func (*CurrencyTransactionMessage) GetDependency

func (m *CurrencyTransactionMessage) GetDependency() []byte

func (*CurrencyTransactionMessage) GetTo

func (m *CurrencyTransactionMessage) GetTo() []byte

func (*CurrencyTransactionMessage) ProtoMessage

func (*CurrencyTransactionMessage) ProtoMessage()

func (*CurrencyTransactionMessage) Reset

func (m *CurrencyTransactionMessage) Reset()

func (*CurrencyTransactionMessage) String

func (m *CurrencyTransactionMessage) String() string

func (*CurrencyTransactionMessage) XXX_DiscardUnknown

func (m *CurrencyTransactionMessage) XXX_DiscardUnknown()

func (*CurrencyTransactionMessage) XXX_Marshal

func (m *CurrencyTransactionMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CurrencyTransactionMessage) XXX_Merge

func (m *CurrencyTransactionMessage) XXX_Merge(src proto.Message)

func (*CurrencyTransactionMessage) XXX_Size

func (m *CurrencyTransactionMessage) XXX_Size() int

func (*CurrencyTransactionMessage) XXX_Unmarshal

func (m *CurrencyTransactionMessage) XXX_Unmarshal(b []byte) error

type DummyApp

type DummyApp struct {
	// contains filtered or unexported fields
}

func (*DummyApp) BlockHead

func (app *DummyApp) BlockHead() []byte

func (*DummyApp) GenerateTransaction

func (app *DummyApp) GenerateTransaction(puts map[string]string) Message

func (*DummyApp) Get

func (app *DummyApp) Get(key string) string

func (*DummyApp) Namespace

func (app *DummyApp) Namespace() [namespaceSize]byte

func (*DummyApp) ProcessMessage

func (app *DummyApp) ProcessMessage(message Message)

func (*DummyApp) SetBlockHead

func (app *DummyApp) SetBlockHead(hash []byte)

func (*DummyApp) StorageSize

func (app *DummyApp) StorageSize() int

type DummyAppTransaction

type DummyAppTransaction struct {
	Puts                 map[string]string `` /* 128-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

func (*DummyAppTransaction) Descriptor

func (*DummyAppTransaction) Descriptor() ([]byte, []int)

func (*DummyAppTransaction) GetPuts

func (m *DummyAppTransaction) GetPuts() map[string]string

func (*DummyAppTransaction) ProtoMessage

func (*DummyAppTransaction) ProtoMessage()

func (*DummyAppTransaction) Reset

func (m *DummyAppTransaction) Reset()

func (*DummyAppTransaction) String

func (m *DummyAppTransaction) String() string

func (*DummyAppTransaction) XXX_DiscardUnknown

func (m *DummyAppTransaction) XXX_DiscardUnknown()

func (*DummyAppTransaction) XXX_Marshal

func (m *DummyAppTransaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DummyAppTransaction) XXX_Merge

func (m *DummyAppTransaction) XXX_Merge(src proto.Message)

func (*DummyAppTransaction) XXX_Size

func (m *DummyAppTransaction) XXX_Size() int

func (*DummyAppTransaction) XXX_Unmarshal

func (m *DummyAppTransaction) XXX_Unmarshal(b []byte) error

type Flagger

type Flagger interface {
	// LeafFlag returns the flag of a raw unhashed leaf.
	LeafFlag([]byte) []byte

	// NodeFlag returns the flag of an intermediate node.
	NodeFlag([]byte) []byte

	// Union returns the union of two flags.
	Union([]byte, []byte) []byte

	// FlagSize returns the number of bytes that LeafFlag or Union will return.
	FlagSize() int
}

Flagger is an interface for computing the flags of bytes of data.

func NewNamespaceDummyFlagger

func NewNamespaceDummyFlagger() Flagger

NewNamespaceDummyFlagger returns a new dummy flagger for namespaced Merkle trees.

type HashLeafHasher

type HashLeafHasher struct {
	// contains filtered or unexported fields
}

HashLeafHasher implements the merkletree.LeafHasher interface from a slice of hashes.

func NewHashLeafHasher

func NewHashLeafHasher(hashes [][]byte) *HashLeafHasher

NewHashLeafHasher returns a new MessageLeafHasher for a slice of hashes.

func (*HashLeafHasher) NextLeafHash

func (hlh *HashLeafHasher) NextLeafHash() (leafHash []byte, err error)

NextLeafHash implements LeafHasher

type InvalidKeyError

type InvalidKeyError struct {
	Key []byte
}

InvalidKeyError is thrown when a key that does not exist is being accessed.

func (*InvalidKeyError) Error

func (e *InvalidKeyError) Error() string

type MapStore

type MapStore interface {
	Get(key []byte) ([]byte, error)     // Get gets the value for a key.
	Put(key []byte, value []byte) error // Put updates the value for a key.
	Del(key []byte) error               // Del deletes a key.
	// contains filtered or unexported methods
}

MapStore is a key-value store.

type Message

type Message struct {
	// contains filtered or unexported fields
}

Message represents a namespaced message.

func NewMessage

func NewMessage(namespace [namespaceSize]byte, data []byte) *Message

NewMessage returns a new message from its namespace and data.

func UnmarshalMessage

func UnmarshalMessage(marshalled []byte) *Message

UnmarshalMessage returns a message from its marshalled raw data.

func UnmarshalPaddedMessage

func UnmarshalPaddedMessage(marshalled []byte) *Message

UnmarshalPaddedMessage returns a message from its marshalled padded raw data.

func (*Message) Data

func (m *Message) Data() []byte

Data returns the data of a message.

func (*Message) Marshal

func (m *Message) Marshal() []byte

Marshal converts a message to raw data.

func (*Message) MarshalPadded

func (m *Message) MarshalPadded(messageSize int) []byte

Marshal converts a message to padded raw data.

func (*Message) Namespace

func (m *Message) Namespace() [namespaceSize]byte

Namespace returns the namespace of a message.

type MessageLeafHasher

type MessageLeafHasher struct {
	// contains filtered or unexported fields
}

MessageLeafHasher implements the merkletree.LeafHasher interface by reading leaf data from an underlying slice of messages.

func NewMessageLeafHasher

func NewMessageLeafHasher(messages *[]Message, h hash.Hash) *MessageLeafHasher

NewMessageLeafHasher returns a new MessageLeafHasher for a pointer to a slice of messages.

func NewPaddedMessageLeafHasher

func NewPaddedMessageLeafHasher(messages *[]Message, h hash.Hash, messageSize int) *MessageLeafHasher

NewPaddedMessageLeafHasher returns a new MessageLeafHasher for a pointer to a slice of messages, where messages should be padded.

func (*MessageLeafHasher) NextLeafHash

func (mlh *MessageLeafHasher) NextLeafHash() (leafHash []byte, err error)

NextLeafHash implements LeafHasher

type MessageSubtreeHasher

type MessageSubtreeHasher struct {
	// contains filtered or unexported fields
}

MessageSubtreeHasher implements merkletree.SubtreeHasher by reading leaf data from an underlying slice of messages.

func NewMessageSubtreeHasher

func NewMessageSubtreeHasher(messages *[]Message, h hash.Hash) *MessageSubtreeHasher

NewMessageSubtreeHasher returns a new MessageSubtreeHasher for a pointer to a slice of messages.

func (*MessageSubtreeHasher) NextSubtreeRoot

func (msh *MessageSubtreeHasher) NextSubtreeRoot(subtreeSize int) ([]byte, error)

NextSubtreeRoot implements SubtreeHasher.

func (*MessageSubtreeHasher) Skip

func (msh *MessageSubtreeHasher) Skip(n int) error

Skip implements SubtreeHasher.

type PetitionApp

type PetitionApp struct {
	// contains filtered or unexported fields
}

func (*PetitionApp) BlockHead

func (app *PetitionApp) BlockHead() []byte

func (*PetitionApp) GenerateAddPetitionTransaction

func (app *PetitionApp) GenerateAddPetitionTransaction(text string) Message

func (*PetitionApp) GenerateSignPetitionTransaction

func (app *PetitionApp) GenerateSignPetitionTransaction(key crypto.PrivKey, petition uint64) Message

func (*PetitionApp) Namespace

func (app *PetitionApp) Namespace() [namespaceSize]byte

func (*PetitionApp) Petition

func (app *PetitionApp) Petition(petition uint64) uint64

func (*PetitionApp) ProcessAddPetitionMessage

func (app *PetitionApp) ProcessAddPetitionMessage(apm *AddPetitionMessage)

func (*PetitionApp) ProcessMessage

func (app *PetitionApp) ProcessMessage(message Message)

func (*PetitionApp) ProcessSignPetitionMessage

func (app *PetitionApp) ProcessSignPetitionMessage(spm *SignPetitionMessage)

func (*PetitionApp) SetBlockHead

func (app *PetitionApp) SetBlockHead(hash []byte)

type PetitionAppTransaction

type PetitionAppTransaction struct {
	// Types that are valid to be assigned to Message:
	//	*PetitionAppTransaction_Apm
	//	*PetitionAppTransaction_Spm
	Message              isPetitionAppTransaction_Message `protobuf_oneof:"message"`
	XXX_NoUnkeyedLiteral struct{}                         `json:"-"`
	XXX_unrecognized     []byte                           `json:"-"`
	XXX_sizecache        int32                            `json:"-"`
}

func (*PetitionAppTransaction) Descriptor

func (*PetitionAppTransaction) Descriptor() ([]byte, []int)

func (*PetitionAppTransaction) GetApm

func (*PetitionAppTransaction) GetMessage

func (m *PetitionAppTransaction) GetMessage() isPetitionAppTransaction_Message

func (*PetitionAppTransaction) GetSpm

func (*PetitionAppTransaction) ProtoMessage

func (*PetitionAppTransaction) ProtoMessage()

func (*PetitionAppTransaction) Reset

func (m *PetitionAppTransaction) Reset()

func (*PetitionAppTransaction) String

func (m *PetitionAppTransaction) String() string

func (*PetitionAppTransaction) XXX_DiscardUnknown

func (m *PetitionAppTransaction) XXX_DiscardUnknown()

func (*PetitionAppTransaction) XXX_Marshal

func (m *PetitionAppTransaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PetitionAppTransaction) XXX_Merge

func (m *PetitionAppTransaction) XXX_Merge(src proto.Message)

func (*PetitionAppTransaction) XXX_OneofWrappers

func (*PetitionAppTransaction) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*PetitionAppTransaction) XXX_Size

func (m *PetitionAppTransaction) XXX_Size() int

func (*PetitionAppTransaction) XXX_Unmarshal

func (m *PetitionAppTransaction) XXX_Unmarshal(b []byte) error

type PetitionAppTransaction_Apm

type PetitionAppTransaction_Apm struct {
	Apm *AddPetitionMessage `protobuf:"bytes,1,opt,name=apm,oneof"`
}

type PetitionAppTransaction_Spm

type PetitionAppTransaction_Spm struct {
	Spm *SignPetitionMessage `protobuf:"bytes,2,opt,name=spm,oneof"`
}

type ProbabilisticBlock

type ProbabilisticBlock struct {
	// contains filtered or unexported fields
}

ProbabilisticBlock represents a block designed for the Probabilistic Validity Rule.

func (*ProbabilisticBlock) AddMessage

func (pb *ProbabilisticBlock) AddMessage(message Message)

AddMessage adds a message to the block.

func (*ProbabilisticBlock) ApplicationProof

func (pb *ProbabilisticBlock) ApplicationProof(namespace [namespaceSize]byte) (int, int, [][][]byte, *[]Message, [][]byte)

ApplicationProof creates a Merkle proof for all of the messages in a block for an application namespace. All proofs are created from row roots only.

func (*ProbabilisticBlock) ColumnRoots

func (pb *ProbabilisticBlock) ColumnRoots() [][]byte

ColumnRoots returns the Merkle roots of the columns of the block.

func (*ProbabilisticBlock) DependencyProven

func (pb *ProbabilisticBlock) DependencyProven(hash []byte) bool

func (*ProbabilisticBlock) Digest

func (pb *ProbabilisticBlock) Digest() []byte

Digest computes the hash of the block.

func (*ProbabilisticBlock) Messages

func (pb *ProbabilisticBlock) Messages() []Message

Messages returns the block's messages.

func (*ProbabilisticBlock) PrevHash

func (pb *ProbabilisticBlock) PrevHash() []byte

PrevHash returns the hash of the previous block.

func (*ProbabilisticBlock) ProcessSamplesResponse

func (pb *ProbabilisticBlock) ProcessSamplesResponse(response *SampleResponse) bool

func (*ProbabilisticBlock) ProveDependency

func (pb *ProbabilisticBlock) ProveDependency(index int) ([]byte, [][]byte, error)

func (*ProbabilisticBlock) RequestSamples

func (pb *ProbabilisticBlock) RequestSamples(n int) (*SampleRequest, error)

func (*ProbabilisticBlock) RespondSamples

func (pb *ProbabilisticBlock) RespondSamples(request *SampleRequest) *SampleResponse

func (*ProbabilisticBlock) RowRoots

func (pb *ProbabilisticBlock) RowRoots() [][]byte

RowRoots returns the Merkle roots of the rows of the block.

func (*ProbabilisticBlock) SquareWidth

func (pb *ProbabilisticBlock) SquareWidth() int

SquareWidth returns the width of coded data square of the block.

func (*ProbabilisticBlock) Valid

func (pb *ProbabilisticBlock) Valid() bool

Valid returns true if the block is valid.

func (*ProbabilisticBlock) VerifyApplicationProof

func (pb *ProbabilisticBlock) VerifyApplicationProof(namespace [namespaceSize]byte, proofStart int, proofEnd int, proofs [][][]byte, messages *[]Message, hashes [][]byte) bool

VerifyApplicationProof verifies a Merkle proof for all of the messages in a block for an application namespace.

func (*ProbabilisticBlock) VerifyDependency

func (pb *ProbabilisticBlock) VerifyDependency(index int, hash []byte, proof [][]byte) bool

type RegisterTransaction

type RegisterTransaction struct {
	Owner                []byte   `protobuf:"bytes,1,req,name=owner" json:"owner,omitempty"`
	Name                 []byte   `protobuf:"bytes,2,req,name=name" json:"name,omitempty"`
	Signature            []byte   `protobuf:"bytes,3,req,name=signature" json:"signature,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*RegisterTransaction) Descriptor

func (*RegisterTransaction) Descriptor() ([]byte, []int)

func (*RegisterTransaction) GetName

func (m *RegisterTransaction) GetName() []byte

func (*RegisterTransaction) GetOwner

func (m *RegisterTransaction) GetOwner() []byte

func (*RegisterTransaction) GetSignature

func (m *RegisterTransaction) GetSignature() []byte

func (*RegisterTransaction) ProtoMessage

func (*RegisterTransaction) ProtoMessage()

func (*RegisterTransaction) Reset

func (m *RegisterTransaction) Reset()

func (*RegisterTransaction) String

func (m *RegisterTransaction) String() string

func (*RegisterTransaction) XXX_DiscardUnknown

func (m *RegisterTransaction) XXX_DiscardUnknown()

func (*RegisterTransaction) XXX_Marshal

func (m *RegisterTransaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RegisterTransaction) XXX_Merge

func (m *RegisterTransaction) XXX_Merge(src proto.Message)

func (*RegisterTransaction) XXX_Size

func (m *RegisterTransaction) XXX_Size() int

func (*RegisterTransaction) XXX_Unmarshal

func (m *RegisterTransaction) XXX_Unmarshal(b []byte) error

type RegisterTransactionMessage

type RegisterTransactionMessage struct {
	Name                 []byte   `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*RegisterTransactionMessage) Descriptor

func (*RegisterTransactionMessage) Descriptor() ([]byte, []int)

func (*RegisterTransactionMessage) GetName

func (m *RegisterTransactionMessage) GetName() []byte

func (*RegisterTransactionMessage) ProtoMessage

func (*RegisterTransactionMessage) ProtoMessage()

func (*RegisterTransactionMessage) Reset

func (m *RegisterTransactionMessage) Reset()

func (*RegisterTransactionMessage) String

func (m *RegisterTransactionMessage) String() string

func (*RegisterTransactionMessage) XXX_DiscardUnknown

func (m *RegisterTransactionMessage) XXX_DiscardUnknown()

func (*RegisterTransactionMessage) XXX_Marshal

func (m *RegisterTransactionMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RegisterTransactionMessage) XXX_Merge

func (m *RegisterTransactionMessage) XXX_Merge(src proto.Message)

func (*RegisterTransactionMessage) XXX_Size

func (m *RegisterTransactionMessage) XXX_Size() int

func (*RegisterTransactionMessage) XXX_Unmarshal

func (m *RegisterTransactionMessage) XXX_Unmarshal(b []byte) error

type Registrar

type Registrar struct {
	// contains filtered or unexported fields
}

func (*Registrar) Balance

func (app *Registrar) Balance(key []byte) uint64

func (*Registrar) BlockHead

func (app *Registrar) BlockHead() []byte

func (*Registrar) GenerateTransaction

func (app *Registrar) GenerateTransaction(owner crypto.PrivKey, name []byte) Message

func (*Registrar) Name

func (app *Registrar) Name(name []byte) []byte

func (*Registrar) Namespace

func (app *Registrar) Namespace() [namespaceSize]byte

func (*Registrar) ProcessMessage

func (app *Registrar) ProcessMessage(message Message)

func (*Registrar) SetBlockHead

func (app *Registrar) SetBlockHead(hash []byte)

func (*Registrar) SetNamespace

func (app *Registrar) SetNamespace(namespace [namespaceSize]byte)

type SampleRequest

type SampleRequest struct {
	Indexes []int
	Axes    []int
}

type SampleResponse

type SampleResponse struct {
	Proofs [][][]byte
}

type SignPetitionMessage

type SignPetitionMessage struct {
	Id                   *uint64  `protobuf:"varint,1,req,name=id" json:"id,omitempty"`
	Signature            []byte   `protobuf:"bytes,2,req,name=signature" json:"signature,omitempty"`
	Signer               []byte   `protobuf:"bytes,3,req,name=signer" json:"signer,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*SignPetitionMessage) Descriptor

func (*SignPetitionMessage) Descriptor() ([]byte, []int)

func (*SignPetitionMessage) GetId

func (m *SignPetitionMessage) GetId() uint64

func (*SignPetitionMessage) GetSignature

func (m *SignPetitionMessage) GetSignature() []byte

func (*SignPetitionMessage) GetSigner

func (m *SignPetitionMessage) GetSigner() []byte

func (*SignPetitionMessage) ProtoMessage

func (*SignPetitionMessage) ProtoMessage()

func (*SignPetitionMessage) Reset

func (m *SignPetitionMessage) Reset()

func (*SignPetitionMessage) String

func (m *SignPetitionMessage) String() string

func (*SignPetitionMessage) XXX_DiscardUnknown

func (m *SignPetitionMessage) XXX_DiscardUnknown()

func (*SignPetitionMessage) XXX_Marshal

func (m *SignPetitionMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SignPetitionMessage) XXX_Merge

func (m *SignPetitionMessage) XXX_Merge(src proto.Message)

func (*SignPetitionMessage) XXX_Size

func (m *SignPetitionMessage) XXX_Size() int

func (*SignPetitionMessage) XXX_Unmarshal

func (m *SignPetitionMessage) XXX_Unmarshal(b []byte) error

type SimpleBlock

type SimpleBlock struct {
	// contains filtered or unexported fields
}

SimpleBlock represents a block designed for the Simple Validity Rule.

func (*SimpleBlock) AddMessage

func (sb *SimpleBlock) AddMessage(message Message)

AddMessage adds a message to the block.

func (*SimpleBlock) ApplicationProof

func (sb *SimpleBlock) ApplicationProof(namespace [namespaceSize]byte) (int, int, [][]byte, *[]Message, [][]byte)

ApplicationProof creates a Merkle proof for all of the messages in a block for an application namespace.

func (*SimpleBlock) DependencyProven

func (sb *SimpleBlock) DependencyProven(hash []byte) bool

func (*SimpleBlock) Digest

func (sb *SimpleBlock) Digest() []byte

Digest computes the hash of the block.

func (*SimpleBlock) Messages

func (sb *SimpleBlock) Messages() []Message

Messages returns the block's messages.

func (*SimpleBlock) MessagesRoot

func (sb *SimpleBlock) MessagesRoot() []byte

MessagesRoot returns the Merkle root of the messages in the block.

func (*SimpleBlock) PrevHash

func (sb *SimpleBlock) PrevHash() []byte

PrevHash returns the hash of the previous block.

func (*SimpleBlock) ProveDependency

func (sb *SimpleBlock) ProveDependency(index int) ([]byte, [][]byte, error)

func (*SimpleBlock) Valid

func (sb *SimpleBlock) Valid() bool

Valid returns true if the block is valid.

func (*SimpleBlock) VerifyApplicationProof

func (sb *SimpleBlock) VerifyApplicationProof(namespace [namespaceSize]byte, proofStart int, proofEnd int, proof [][]byte, messages *[]Message, hashes [][]byte) bool

VerifyApplicationProof verifies a Merkle proof for all of the messages in a block for an application namespace.

func (*SimpleBlock) VerifyDependency

func (sb *SimpleBlock) VerifyDependency(index int, hash []byte, proof [][]byte) bool

type SimpleBlockStore

type SimpleBlockStore struct {
	// contains filtered or unexported fields
}

SimpleBlockStore is a simple in-memory block store.

func NewSimpleBlockStore

func NewSimpleBlockStore() *SimpleBlockStore

NewSimpleBlockStore creates a new empty simple block store.

func (*SimpleBlockStore) Del

func (sbs *SimpleBlockStore) Del(key []byte) error

Del deletes a key.

func (*SimpleBlockStore) Get

func (sbs *SimpleBlockStore) Get(key []byte) (Block, error)

Get gets the value for a key.

func (*SimpleBlockStore) Put

func (sbs *SimpleBlockStore) Put(key []byte, value Block) error

Put updates the value for a key.

type SimpleMap

type SimpleMap struct {
	// contains filtered or unexported fields
}

SimpleMap is a simple in-memory map.

func NewSimpleMap

func NewSimpleMap() *SimpleMap

NewSimpleMap creates a new empty SimpleMap.

func (*SimpleMap) Del

func (sm *SimpleMap) Del(key []byte) error

Del deletes a key.

func (*SimpleMap) Get

func (sm *SimpleMap) Get(key []byte) ([]byte, error)

Get gets the value for a key.

func (*SimpleMap) Put

func (sm *SimpleMap) Put(key []byte, value []byte) error

Put updates the value for a key.

type TransferCallback

type TransferCallback = func(from []byte, to []byte, value int)

Jump to

Keyboard shortcuts

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