protocol

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: Apache-2.0 Imports: 11 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTokenTypeFromBuf

func NewTokenTypeFromBuf(buf *TokenTypeBuf) [21]byte

func TokenTypeArrayEncoded

func TokenTypeArrayEncoded(input [][21]byte) []byte

Types

type Assertion

type Assertion struct {
	AfterHash [32]byte
	NumSteps  uint32
	OutMsgs   []Message
	Logs      []value.Value
}

func NewAssertion

func NewAssertion(afterHash [32]byte, numSteps uint32, outMsgs []Message, logs []value.Value) *Assertion

func NewAssertionFromBuf

func NewAssertionFromBuf(buf *AssertionBuf) (*Assertion, error)

func NewAssertionFromReader

func NewAssertionFromReader(rd io.Reader) (*Assertion, error)

func (*Assertion) Equals

func (a *Assertion) Equals(b *Assertion) bool

func (*Assertion) LogsHash

func (a *Assertion) LogsHash() [32]byte

func (*Assertion) Marshal

func (a *Assertion) Marshal(wr io.Writer) error

func (*Assertion) Stub

func (a *Assertion) Stub() *AssertionStub

type AssertionBuf

type AssertionBuf struct {
	AfterHash            *value.HashBuf    `protobuf:"bytes,1,opt,name=afterHash,proto3" json:"afterHash,omitempty"`
	NumSteps             uint32            `protobuf:"varint,2,opt,name=numSteps,proto3" json:"numSteps,omitempty"`
	Messages             []*MessageBuf     `protobuf:"bytes,3,rep,name=messages,proto3" json:"messages,omitempty"`
	Logs                 []*value.ValueBuf `protobuf:"bytes,4,rep,name=logs,proto3" json:"logs,omitempty"`
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

func NewAssertionBuf

func NewAssertionBuf(a *Assertion) *AssertionBuf

func (*AssertionBuf) Descriptor

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

func (*AssertionBuf) GetAfterHash

func (m *AssertionBuf) GetAfterHash() *value.HashBuf

func (*AssertionBuf) GetLogs

func (m *AssertionBuf) GetLogs() []*value.ValueBuf

func (*AssertionBuf) GetMessages

func (m *AssertionBuf) GetMessages() []*MessageBuf

func (*AssertionBuf) GetNumSteps

func (m *AssertionBuf) GetNumSteps() uint32

func (*AssertionBuf) ProtoMessage

func (*AssertionBuf) ProtoMessage()

func (*AssertionBuf) Reset

func (m *AssertionBuf) Reset()

func (*AssertionBuf) String

func (m *AssertionBuf) String() string

func (*AssertionBuf) XXX_DiscardUnknown

func (m *AssertionBuf) XXX_DiscardUnknown()

func (*AssertionBuf) XXX_Marshal

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

func (*AssertionBuf) XXX_Merge

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

func (*AssertionBuf) XXX_Size

func (m *AssertionBuf) XXX_Size() int

func (*AssertionBuf) XXX_Unmarshal

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

type AssertionStub

type AssertionStub struct {
	AfterHash        [32]byte
	NumSteps         uint32
	FirstMessageHash [32]byte
	LastMessageHash  [32]byte
	FirstLogHash     [32]byte
	LastLogHash      [32]byte
	TotalVals        []*big.Int
}

func NewAssertionStubFromReader

func NewAssertionStubFromReader(rd io.Reader) (AssertionStub, error)

func (*AssertionStub) Equals

func (a *AssertionStub) Equals(b *AssertionStub) bool

func (*AssertionStub) GeneratePostcondition

func (a *AssertionStub) GeneratePostcondition(pre *Precondition) *Precondition

func (*AssertionStub) Hash

func (a *AssertionStub) Hash() [32]byte

func (*AssertionStub) Marshal

func (a *AssertionStub) Marshal(wr io.Writer) error

func (*AssertionStub) String

func (a *AssertionStub) String() string

type BalanceTracker

type BalanceTracker struct {
	TokenTypes   [][21]byte
	TokenAmounts []*big.Int
	TokenLookup  map[TokenType]int
	NFTLookup    map[nftKey]int
}

func NewBalanceTracker

func NewBalanceTracker() *BalanceTracker

func NewBalanceTrackerFromBuf

func NewBalanceTrackerFromBuf(buf *BalanceTrackerBuf) *BalanceTracker

func NewBalanceTrackerFromLists

func NewBalanceTrackerFromLists(types [][21]byte, amounts []*big.Int) *BalanceTracker

func NewBalanceTrackerFromMessages

func NewBalanceTrackerFromMessages(msgs []Message) *BalanceTracker

func NewBalanceTrackerFromReader

func NewBalanceTrackerFromReader(rd io.Reader) (*BalanceTracker, error)

func (*BalanceTracker) Add

func (b *BalanceTracker) Add(tokenType TokenType, amount *big.Int)

func (*BalanceTracker) AddAll

func (b *BalanceTracker) AddAll(o *BalanceTracker)

func (*BalanceTracker) CanSpend

func (b *BalanceTracker) CanSpend(tokenType TokenType, amount *big.Int) bool

func (*BalanceTracker) CanSpendAll

func (b *BalanceTracker) CanSpendAll(o *BalanceTracker) bool

func (*BalanceTracker) Clone

func (b *BalanceTracker) Clone() *BalanceTracker

func (*BalanceTracker) Equals

func (b *BalanceTracker) Equals(o *BalanceTracker) bool

func (*BalanceTracker) Marshal

func (b *BalanceTracker) Marshal(wr io.Writer) error

func (*BalanceTracker) Spend

func (b *BalanceTracker) Spend(tokenType TokenType, amount *big.Int) error

func (*BalanceTracker) SpendAll

func (b *BalanceTracker) SpendAll(o *BalanceTracker) error

func (*BalanceTracker) TokenIndex

func (b *BalanceTracker) TokenIndex(tokenType [21]byte, amount *big.Int) int

func (*BalanceTracker) ValidAssertionStub

func (b *BalanceTracker) ValidAssertionStub(a *AssertionStub) bool

type BalanceTrackerBuf

type BalanceTrackerBuf struct {
	Types                []*TokenTypeBuf        `protobuf:"bytes,1,rep,name=types,proto3" json:"types,omitempty"`
	Amounts              []*value.BigIntegerBuf `protobuf:"bytes,2,rep,name=amounts,proto3" json:"amounts,omitempty"`
	XXX_NoUnkeyedLiteral struct{}               `json:"-"`
	XXX_unrecognized     []byte                 `json:"-"`
	XXX_sizecache        int32                  `json:"-"`
}

func NewBalanceTrackerBuf

func NewBalanceTrackerBuf(bt *BalanceTracker) *BalanceTrackerBuf

func (*BalanceTrackerBuf) Descriptor

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

func (*BalanceTrackerBuf) GetAmounts

func (m *BalanceTrackerBuf) GetAmounts() []*value.BigIntegerBuf

func (*BalanceTrackerBuf) GetTypes

func (m *BalanceTrackerBuf) GetTypes() []*TokenTypeBuf

func (*BalanceTrackerBuf) ProtoMessage

func (*BalanceTrackerBuf) ProtoMessage()

func (*BalanceTrackerBuf) Reset

func (m *BalanceTrackerBuf) Reset()

func (*BalanceTrackerBuf) String

func (m *BalanceTrackerBuf) String() string

func (*BalanceTrackerBuf) XXX_DiscardUnknown

func (m *BalanceTrackerBuf) XXX_DiscardUnknown()

func (*BalanceTrackerBuf) XXX_Marshal

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

func (*BalanceTrackerBuf) XXX_Merge

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

func (*BalanceTrackerBuf) XXX_Size

func (m *BalanceTrackerBuf) XXX_Size() int

func (*BalanceTrackerBuf) XXX_Unmarshal

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

type Identity

type Identity [32]byte

type Inbox

type Inbox struct {
	Accepted     *MessageQueues
	PendingQueue *MessageQueue
}

func NewEmptyInbox

func NewEmptyInbox() *Inbox

func NewInbox

func NewInbox(inbox *MessageQueues, pending *MessageQueue) *Inbox

func (*Inbox) Clone

func (in *Inbox) Clone() *Inbox

func (*Inbox) DeliverMessages

func (in *Inbox) DeliverMessages()

func (*Inbox) InsertMessageGroup

func (in *Inbox) InsertMessageGroup(msgs []Message)

func (*Inbox) InsertMessageQueue

func (in *Inbox) InsertMessageQueue(mq *MessageQueue)

func (*Inbox) Pending

func (in *Inbox) Pending() value.TupleValue

func (*Inbox) Receive

func (in *Inbox) Receive() value.TupleValue

func (*Inbox) ReceivePending

func (in *Inbox) ReceivePending() value.TupleValue

func (*Inbox) SendMessage

func (in *Inbox) SendMessage(msg Message)

func (*Inbox) SendRawMessage

func (in *Inbox) SendRawMessage(msg value.Value)

type Message

type Message struct {
	Data        value.Value
	TokenType   [21]byte
	Currency    *big.Int
	Destination [32]byte
}

func NewMessage

func NewMessage(data value.Value, tokenType [21]byte, currency *big.Int, destination [32]byte) Message

func NewMessageFromBuf

func NewMessageFromBuf(buf *MessageBuf) (Message, error)

func NewMessageFromReader

func NewMessageFromReader(rd io.Reader) (Message, error)

func NewMessageFromValue

func NewMessageFromValue(val value.Value) (Message, error)

func NewSimpleMessage

func NewSimpleMessage(data value.Value, tokenType [21]byte, currency *big.Int, sender common.Address) Message

func (Message) AsValue

func (msg Message) AsValue() value.Value

func (Message) Clone

func (msg Message) Clone() Message

func (Message) Equals

func (msg Message) Equals(b Message) bool

func (Message) Hash

func (msg Message) Hash() [32]byte

func (Message) Marshal

func (msg Message) Marshal(w io.Writer) error

type MessageBuf

type MessageBuf struct {
	Value                *value.ValueBuf      `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	TokenType            *TokenTypeBuf        `protobuf:"bytes,2,opt,name=tokenType,proto3" json:"tokenType,omitempty"`
	Amount               *value.BigIntegerBuf `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"`
	Sender               *value.HashBuf       `protobuf:"bytes,4,opt,name=sender,proto3" json:"sender,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

func NewMessageBuf

func NewMessageBuf(val Message) *MessageBuf

func (*MessageBuf) Descriptor

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

func (*MessageBuf) GetAmount

func (m *MessageBuf) GetAmount() *value.BigIntegerBuf

func (*MessageBuf) GetSender

func (m *MessageBuf) GetSender() *value.HashBuf

func (*MessageBuf) GetTokenType

func (m *MessageBuf) GetTokenType() *TokenTypeBuf

func (*MessageBuf) GetValue

func (m *MessageBuf) GetValue() *value.ValueBuf

func (*MessageBuf) ProtoMessage

func (*MessageBuf) ProtoMessage()

func (*MessageBuf) Reset

func (m *MessageBuf) Reset()

func (*MessageBuf) String

func (m *MessageBuf) String() string

func (*MessageBuf) XXX_DiscardUnknown

func (m *MessageBuf) XXX_DiscardUnknown()

func (*MessageBuf) XXX_Marshal

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

func (*MessageBuf) XXX_Merge

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

func (*MessageBuf) XXX_Size

func (m *MessageBuf) XXX_Size() int

func (*MessageBuf) XXX_Unmarshal

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

type MessageQueue

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

func NewMessageQueue

func NewMessageQueue() *MessageQueue

func (*MessageQueue) AddMessage

func (in *MessageQueue) AddMessage(msg Message)

func (*MessageQueue) AddRawMessage

func (in *MessageQueue) AddRawMessage(msgVal value.Value)

func (*MessageQueue) Clone

func (in *MessageQueue) Clone() *MessageQueue

func (*MessageQueue) IsEmpty

func (in *MessageQueue) IsEmpty() bool

func (*MessageQueue) MessageCount

func (in *MessageQueue) MessageCount() uint64

func (*MessageQueue) String

func (in *MessageQueue) String() string

type MessageQueues

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

func NewMessageQueues

func NewMessageQueues() *MessageQueues

func (*MessageQueues) Clone

func (in *MessageQueues) Clone() *MessageQueues

func (*MessageQueues) String

func (in *MessageQueues) String() string

func (*MessageQueues) WithAddedQueue

func (in *MessageQueues) WithAddedQueue(queue *MessageQueue) *MessageQueues

type MultiReader

type MultiReader interface {
	io.Reader
	io.ByteReader
}

type Precondition

type Precondition struct {
	BeforeHash    [32]byte
	TimeBounds    TimeBounds
	BeforeBalance *BalanceTracker
	BeforeInbox   value.HashOnlyValue
}

func GeneratePreconditions

func GeneratePreconditions(pre *Precondition, assertions []*AssertionStub) []*Precondition

func NewPrecondition

func NewPrecondition(beforeHash [32]byte, timeBounds TimeBounds, beforeBalance *BalanceTracker, beforeInbox value.Value) *Precondition

func NewPreconditionFromBuf

func NewPreconditionFromBuf(buf *PreconditionBuf) *Precondition

func NewPreconditionFromReader

func NewPreconditionFromReader(rd io.Reader) (*Precondition, error)

func (*Precondition) Clone

func (pre *Precondition) Clone() *Precondition

func (*Precondition) Equals

func (pre *Precondition) Equals(b *Precondition) bool

func (*Precondition) Hash

func (pre *Precondition) Hash() [32]byte

func (*Precondition) Marshal

func (pre *Precondition) Marshal(wr io.Writer) error

type PreconditionBuf

type PreconditionBuf struct {
	BeforeHash           *value.HashBuf     `protobuf:"bytes,1,opt,name=beforeHash,proto3" json:"beforeHash,omitempty"`
	TimeBounds           *TimeBoundsBuf     `protobuf:"bytes,2,opt,name=timeBounds,proto3" json:"timeBounds,omitempty"`
	BalanceTracker       *BalanceTrackerBuf `protobuf:"bytes,3,opt,name=balanceTracker,proto3" json:"balanceTracker,omitempty"`
	BeforeInbox          *value.HashBuf     `protobuf:"bytes,4,opt,name=beforeInbox,proto3" json:"beforeInbox,omitempty"`
	XXX_NoUnkeyedLiteral struct{}           `json:"-"`
	XXX_unrecognized     []byte             `json:"-"`
	XXX_sizecache        int32              `json:"-"`
}

func NewPreconditionBuf

func NewPreconditionBuf(pre *Precondition) *PreconditionBuf

func (*PreconditionBuf) Descriptor

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

func (*PreconditionBuf) GetBalanceTracker

func (m *PreconditionBuf) GetBalanceTracker() *BalanceTrackerBuf

func (*PreconditionBuf) GetBeforeHash

func (m *PreconditionBuf) GetBeforeHash() *value.HashBuf

func (*PreconditionBuf) GetBeforeInbox

func (m *PreconditionBuf) GetBeforeInbox() *value.HashBuf

func (*PreconditionBuf) GetTimeBounds

func (m *PreconditionBuf) GetTimeBounds() *TimeBoundsBuf

func (*PreconditionBuf) ProtoMessage

func (*PreconditionBuf) ProtoMessage()

func (*PreconditionBuf) Reset

func (m *PreconditionBuf) Reset()

func (*PreconditionBuf) String

func (m *PreconditionBuf) String() string

func (*PreconditionBuf) XXX_DiscardUnknown

func (m *PreconditionBuf) XXX_DiscardUnknown()

func (*PreconditionBuf) XXX_Marshal

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

func (*PreconditionBuf) XXX_Merge

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

func (*PreconditionBuf) XXX_Size

func (m *PreconditionBuf) XXX_Size() int

func (*PreconditionBuf) XXX_Unmarshal

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

type TimeBounds

type TimeBounds [2]uint64

func NewTimeBounds

func NewTimeBounds(startTime, endTime uint64) TimeBounds

func NewTimeBoundsFromBuf

func NewTimeBoundsFromBuf(buf *TimeBoundsBuf) TimeBounds

func NewTimeBoundsFromReader

func NewTimeBoundsFromReader(rd io.Reader) (TimeBounds, error)

func (TimeBounds) AsValue

func (tb TimeBounds) AsValue() value.Value

func (TimeBounds) Equals

func (tb TimeBounds) Equals(other TimeBounds) bool

func (TimeBounds) IsValidTime

func (tb TimeBounds) IsValidTime(time uint64) error

func (TimeBounds) Marshal

func (tb TimeBounds) Marshal(wr io.Writer) error

type TimeBoundsBuf

type TimeBoundsBuf struct {
	StartTime            uint64   `protobuf:"varint,1,opt,name=startTime,proto3" json:"startTime,omitempty"`
	EndTime              uint64   `protobuf:"varint,2,opt,name=endTime,proto3" json:"endTime,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func NewTimeBoundsBuf

func NewTimeBoundsBuf(tb TimeBounds) *TimeBoundsBuf

func (*TimeBoundsBuf) Descriptor

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

func (*TimeBoundsBuf) GetEndTime

func (m *TimeBoundsBuf) GetEndTime() uint64

func (*TimeBoundsBuf) GetStartTime

func (m *TimeBoundsBuf) GetStartTime() uint64

func (*TimeBoundsBuf) ProtoMessage

func (*TimeBoundsBuf) ProtoMessage()

func (*TimeBoundsBuf) Reset

func (m *TimeBoundsBuf) Reset()

func (*TimeBoundsBuf) String

func (m *TimeBoundsBuf) String() string

func (*TimeBoundsBuf) XXX_DiscardUnknown

func (m *TimeBoundsBuf) XXX_DiscardUnknown()

func (*TimeBoundsBuf) XXX_Marshal

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

func (*TimeBoundsBuf) XXX_Merge

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

func (*TimeBoundsBuf) XXX_Size

func (m *TimeBoundsBuf) XXX_Size() int

func (*TimeBoundsBuf) XXX_Unmarshal

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

type TokenType

type TokenType [21]byte

func TokenTypeFromIntValue

func TokenTypeFromIntValue(val value.IntValue) TokenType

func (TokenType) IsToken

func (t TokenType) IsToken() bool

func (TokenType) ToIntValue

func (t TokenType) ToIntValue() value.IntValue

type TokenTypeBuf

type TokenTypeBuf struct {
	Value                []byte   `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func NewTokenTypeBuf

func NewTokenTypeBuf(tok [21]byte) *TokenTypeBuf

func (*TokenTypeBuf) Descriptor

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

func (*TokenTypeBuf) GetValue

func (m *TokenTypeBuf) GetValue() []byte

func (*TokenTypeBuf) ProtoMessage

func (*TokenTypeBuf) ProtoMessage()

func (*TokenTypeBuf) Reset

func (m *TokenTypeBuf) Reset()

func (*TokenTypeBuf) String

func (m *TokenTypeBuf) String() string

func (*TokenTypeBuf) XXX_DiscardUnknown

func (m *TokenTypeBuf) XXX_DiscardUnknown()

func (*TokenTypeBuf) XXX_Marshal

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

func (*TokenTypeBuf) XXX_Merge

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

func (*TokenTypeBuf) XXX_Size

func (m *TokenTypeBuf) XXX_Size() int

func (*TokenTypeBuf) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

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