statechain

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoHash ...
	ErrNoHash = errors.New("no hash present")
	// ErrNilTx ...
	ErrNilTx = errors.New("transaction is nil")
	// ErrNoSig ...
	ErrNoSig = errors.New("no signature present")
	// ErrInvalidFromAddress ...
	ErrInvalidFromAddress = errors.New("from address is not valid")
	// ErrNilBlock ...
	ErrNilBlock = errors.New("block is nil")
	// ErrNilDiff ...
	ErrNilDiff = errors.New("diff is nil")
)

Functions

func BuildBlockCoderFromBytes

func BuildBlockCoderFromBytes(data []byte) (*coder.StatechainBlock, error)

BuildBlockCoderFromBytes ...

func BuildBytesCoderFromBytes

func BuildBytesCoderFromBytes(data []byte) (*coder.Diff, error)

BuildBytesCoderFromBytes ...

func BuildCoderFromBlock

func BuildCoderFromBlock(b *Block) *coder.StatechainBlock

BuildCoderFromBlock ...

func BuildCoderFromDiff

func BuildCoderFromDiff(d *Diff) *coder.Diff

BuildCoderFromDiff ...

func BuildCoderFromTransaction

func BuildCoderFromTransaction(tx *Transaction) (*coder.Transaction, error)

BuildCoderFromTransaction ...

func BuildTransactionCoderFromBytes

func BuildTransactionCoderFromBytes(data []byte) (*coder.Transaction, error)

BuildTransactionCoderFromBytes ...

Types

type Block

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

Block ...

func New

func New(props *BlockProps) *Block

New ...

func (Block) CalculateHash

func (b Block) CalculateHash() (string, error)

CalculateHash ...

func (Block) CalculateHashBytes

func (b Block) CalculateHashBytes() ([]byte, error)

CalculateHashBytes ...

func (*Block) Deserialize

func (b *Block) Deserialize(data []byte) error

Deserialize ...

func (*Block) DeserializeString

func (b *Block) DeserializeString(hexStr string) error

DeserializeString ...

func (Block) Equals

func (b Block) Equals(other merkletree.Content) (bool, error)

Equals ...

func (*Block) MarshalJSON

func (b *Block) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (Block) Props

func (b Block) Props() BlockProps

Props ...

func (*Block) Serialize

func (b *Block) Serialize() ([]byte, error)

Serialize ...

func (Block) SerializeString

func (b Block) SerializeString() (string, error)

SerializeString ...

func (*Block) SetHash

func (b *Block) SetHash() error

SetHash ...

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(data []byte) error

UnmarshalJSON ...

type BlockProps

type BlockProps struct {
	BlockHash         *string `json:"blockHash,omitempty" rlp:"nil"`
	BlockNumber       string  `json:"blockNumber"`
	BlockTime         string  `json:"blockTime"` // unix timestamp
	ImageHash         string  `json:"imageHash"`
	TxHash            string  `json:"txHash"`
	PrevBlockHash     string  `json:"prevBlockHash"`
	StatePrevDiffHash string  `json:"statePrevDiffHash"`
	StateCurrentHash  string  `json:"stateCurrentHash"`
}

BlockProps ...

func BuildBlockPropsFromBytes

func BuildBlockPropsFromBytes(data []byte) (*BlockProps, error)

BuildBlockPropsFromBytes ...

func BuildBlockPropsFromCoder

func BuildBlockPropsFromCoder(tmp *coder.StatechainBlock) (*BlockProps, error)

BuildBlockPropsFromCoder ...

type Diff

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

Diff ...

func NewDiff

func NewDiff(props *DiffProps) *Diff

NewDiff ...

func (Diff) CalculateHash

func (d Diff) CalculateHash() (string, error)

CalculateHash ...

func (Diff) CalculateHashBytes

func (d Diff) CalculateHashBytes() ([]byte, error)

CalculateHashBytes ...

func (*Diff) Deserialize

func (d *Diff) Deserialize(data []byte) error

Deserialize ...

func (*Diff) DeserializeString

func (d *Diff) DeserializeString(hexStr string) error

DeserializeString ...

func (Diff) Equals

func (d Diff) Equals(other merkletree.Content) (bool, error)

Equals ...

func (*Diff) MarshalJSON

func (d *Diff) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (Diff) Props

func (d Diff) Props() DiffProps

Props ...

func (*Diff) Serialize

func (d *Diff) Serialize() ([]byte, error)

Serialize ...

func (Diff) SerializeString

func (d Diff) SerializeString() (string, error)

SerializeString ...

func (*Diff) SetHash

func (d *Diff) SetHash() error

SetHash ...

func (*Diff) UnmarshalJSON

func (d *Diff) UnmarshalJSON(data []byte) error

UnmarshalJSON ...

type DiffProps

type DiffProps struct {
	DiffHash *string `json:"diffHash,omitempty" rlp:"nil"`
	// what's the best way to store a diff?
	Data string `json:"data"`
}

DiffProps ... note @miguelmota: any better system than simply storing as a string?

func BuildDiffPropsFromBytes

func BuildDiffPropsFromBytes(data []byte) (*DiffProps, error)

BuildDiffPropsFromBytes ...

func BuildDiffPropsFromCoder

func BuildDiffPropsFromCoder(tmp *coder.Diff) (*DiffProps, error)

BuildDiffPropsFromCoder ...

type Transaction

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

Transaction ...

func NewTransaction

func NewTransaction(props *TransactionProps) *Transaction

NewTransaction ...

func (*Transaction) CalcSig

func (tx *Transaction) CalcSig(priv *ecdsa.PrivateKey) (*TxSig, error)

CalcSig ...

func (*Transaction) CalculateHash

func (tx *Transaction) CalculateHash() (string, error)

CalculateHash ...

func (*Transaction) CalculateHashBytes

func (tx *Transaction) CalculateHashBytes() ([]byte, error)

CalculateHashBytes ...

func (*Transaction) Deserialize

func (tx *Transaction) Deserialize(data []byte) error

Deserialize ...

func (*Transaction) DeserializeString

func (tx *Transaction) DeserializeString(hexStr string) error

DeserializeString ...

func (*Transaction) Equals

func (tx *Transaction) Equals(other merkletree.Content) (bool, error)

Equals ...

func (*Transaction) MarshalJSON

func (tx *Transaction) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Transaction) Props

func (tx *Transaction) Props() TransactionProps

Props ...

func (*Transaction) Serialize

func (tx *Transaction) Serialize() ([]byte, error)

Serialize ...

func (*Transaction) SerializeString

func (tx *Transaction) SerializeString() (string, error)

SerializeString ...

func (*Transaction) SetHash

func (tx *Transaction) SetHash() error

SetHash ...

func (*Transaction) SetSig

func (tx *Transaction) SetSig(priv *ecdsa.PrivateKey) error

SetSig ...

func (*Transaction) UnmarshalJSON

func (tx *Transaction) UnmarshalJSON(data []byte) error

UnmarshalJSON ...

type TransactionProps

type TransactionProps struct {
	TxHash    *string `json:"txHash,omitempty" rlp:"nil"`
	ImageHash string  `json:"imageHash"`
	Method    string  `json:"method"`
	Payload   []byte  `json:"payload"`
	From      string  `json:"from"`
	Sig       *TxSig  `json:"txSig,omitempty" rlp:"nil"`
}

TransactionProps ...

func BuildTransactionPropsFromBytes

func BuildTransactionPropsFromBytes(data []byte) (*TransactionProps, error)

BuildTransactionPropsFromBytes ...

func BuildTransactionPropsFromCoder

func BuildTransactionPropsFromCoder(tmp *coder.Transaction) (*TransactionProps, error)

BuildTransactionPropsFromCoder ...

type TransactionsMap

type TransactionsMap map[string][]*Transaction

TransactionsMap is a list of transactions by image hashes

type TxSig

type TxSig struct {
	R string `json:"r"`
	S string `json:"s"`
}

TxSig ...

Jump to

Keyboard shortcuts

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