types

package
v0.0.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dumpable

type Dumpable interface {
	Dump() string
}

type Hashable

type Hashable interface {
	CalcTxHash() types.Hash // TxHash returns a full tx common.Hash (parents sealed by PoW stage 2)
}

type Sequencer

type Sequencer struct {
	// graph structure info
	Hash         types.Hash
	ParentsHash  types.Hashes
	Height       uint64
	MineNonce    uint64
	AccountNonce uint64
	Issuer       common.Address
	Signature    hexutil.Bytes
	PublicKey    hexutil.Bytes
	StateRoot    types.Hash

	// derived properties
	Weight uint64
	// contains filtered or unexported fields
}

Sequencer is the block generated by consensus to confirm the graph

func (*Sequencer) CalculateWeight

func (s *Sequencer) CalculateWeight(parents Txis) uint64

func (*Sequencer) Compare

func (s *Sequencer) Compare(tx Txi) bool

func (*Sequencer) Dump

func (s *Sequencer) Dump() string

func (*Sequencer) GetHash

func (s *Sequencer) GetHash() types.Hash

func (*Sequencer) GetHeight

func (s *Sequencer) GetHeight() uint64

func (*Sequencer) GetNonce

func (s *Sequencer) GetNonce() uint64

func (*Sequencer) GetParents

func (s *Sequencer) GetParents() types.Hashes

func (*Sequencer) GetType

func (s *Sequencer) GetType() TxBaseType

func (*Sequencer) GetWeight

func (s *Sequencer) GetWeight() uint64

func (*Sequencer) Sender

func (s *Sequencer) Sender() common.Address

func (*Sequencer) SetHash

func (s *Sequencer) SetHash(h types.Hash)

func (*Sequencer) SetHeight

func (s *Sequencer) SetHeight(height uint64)

func (*Sequencer) SetMineNonce

func (s *Sequencer) SetMineNonce(v uint64)

func (*Sequencer) SetParents

func (s *Sequencer) SetParents(hashes types.Hashes)

func (*Sequencer) SetSender

func (s *Sequencer) SetSender(addr common.Address)

func (*Sequencer) SetValid

func (s *Sequencer) SetValid(b bool)

func (*Sequencer) SetWeight

func (s *Sequencer) SetWeight(weight uint64)

func (*Sequencer) SignatureTargets

func (s *Sequencer) SignatureTargets() []byte

func (*Sequencer) String

func (s *Sequencer) String() string

func (*Sequencer) Valid

func (s *Sequencer) Valid() bool

type Signable

type Signable interface {
	SignatureTargets() []byte
}

type Tx

type Tx struct {
	// graph structure info
	Hash        types.Hash
	ParentsHash types.Hashes
	MineNonce   uint64

	// tx info
	AccountNonce uint64
	From         common.Address
	To           common.Address
	Value        *math.BigInt
	TokenId      int32
	Data         []byte
	PublicKey    crypto.PublicKey
	Signature    crypto.Signature

	// Derived properties
	Height uint64
	Weight uint64
	// contains filtered or unexported fields
}

func (*Tx) CalculateWeight

func (t *Tx) CalculateWeight(parents Txis) uint64

CalculateWeight a core algorithm for tx sorting, a tx's weight must bigger than any of it's parent's weight and bigger than any of it's elder transaction's

func (*Tx) Compare

func (t *Tx) Compare(tx Txi) bool

func (*Tx) DebugString

func (t *Tx) DebugString() string

func (*Tx) Dump

func (t *Tx) Dump() string

func (*Tx) GetHash

func (t *Tx) GetHash() types.Hash

func (*Tx) GetHeight

func (t *Tx) GetHeight() uint64

func (*Tx) GetNonce

func (t *Tx) GetNonce() uint64

func (*Tx) GetParents

func (t *Tx) GetParents() types.Hashes

func (*Tx) GetType

func (t *Tx) GetType() TxBaseType

func (*Tx) GetWeight

func (t *Tx) GetWeight() uint64

func (*Tx) Sender

func (t *Tx) Sender() common.Address

func (*Tx) SetHash

func (t *Tx) SetHash(h types.Hash)

func (*Tx) SetHeight

func (t *Tx) SetHeight(height uint64)

func (*Tx) SetMineNonce

func (t *Tx) SetMineNonce(v uint64)

func (*Tx) SetParents

func (t *Tx) SetParents(hashes types.Hashes)

func (*Tx) SetSender

func (t *Tx) SetSender(addr common.Address)

func (*Tx) SetValid

func (t *Tx) SetValid(b bool)

func (*Tx) SetWeight

func (t *Tx) SetWeight(weight uint64)

func (*Tx) SignatureTargets

func (t *Tx) SignatureTargets() []byte

func (*Tx) String

func (t *Tx) String() string

func (*Tx) Valid

func (t *Tx) Valid() bool

type TxBase

type TxBase struct {
	//	Type         TxBaseType
	Hash        types.Hash
	ParentsHash types.Hashes
	//	AccountNonce uint64
	Height uint64
}

type TxBaseType

type TxBaseType uint8
const (
	TxBaseTypeTx TxBaseType = iota
	TxBaseTypeSequencer
)

type Txi

type Txi interface {
	// Implemented by TxBase
	GetType() TxBaseType
	GetHeight() uint64
	SetHeight(uint64)
	GetWeight() uint64
	SetWeight(weight uint64)
	GetHash() types.Hash
	GetParents() types.Hashes // GetParents returns the common.Hash of txs that it directly proves.
	SetParents(hashes types.Hashes)
	String() string

	CalculateWeight(parents Txis) uint64
	Compare(tx Txi) bool      // Compare compares two txs, return true if they are the same.
	SignatureTargets() []byte // SignatureTargets only returns the parts that needs to be signed by sender.
	GetNonce() uint64

	SetMineNonce(uint64)

	SetHash(h types.Hash)
	SetValid(b bool)
	Valid() bool

	// implemented by each tx type
	//GetBase() *TxBase
	Sender() common.Address
	//GetSender() *common.Address
	SetSender(addr common.Address)
}

Txi represents the basic structure that will exist on the DAG graph There may be many implementations of Txi so that the graph structure can support multiple tx types. Note: All fields not related to graph strcuture should be implemented in their own struct, not interface

type Txis

type Txis []Txi

func (Txis) Len

func (t Txis) Len() int

func (Txis) Less

func (t Txis) Less(i, j int) bool

func (Txis) String

func (t Txis) String() string

func (Txis) Swap

func (t Txis) Swap(i, j int)

Jump to

Keyboard shortcuts

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