types

package
v0.0.0-...-c820c6a Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address string

func ParseAddress

func ParseAddress(s string) (Address, error)

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) error

type Block

type Block struct {
	Parent *cid.Cid

	// could use a hamt for these, really only need a set. a merkle patricia
	// trie (or radix trie, to be technically correct, thanks @wanderer) is
	// inefficient due to all the branch nodes
	// the important thing here is minizing the number of intermediate nodes
	// the simplest thing might just be to use a sorted list of cids for now.
	// A simple array can fit over 5000 cids in a single 256k block.
	//Txs *cid.Cid
	Txs []*Transaction

	// structure should probably mirror the transactions
	Receipts []*Receipt

	// Height is the chain height of this block
	Height uint64

	// StateRoot should be a HAMT, its a very efficient KV store
	StateRoot *cid.Cid

	TickLimit *big.Int
	TicksUsed *big.Int
}

func DecodeBlock

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

func (*Block) Cid

func (b *Block) Cid() *cid.Cid

func (*Block) Score

func (b *Block) Score() uint64

Score returns a score for this block. This is used to choose the best chain.

func (*Block) ToNode

func (b *Block) ToNode() node.Node

type Receipt

type Receipt struct {
	Success bool
	Result  interface{}
}

type Signature

type Signature struct {
	V *big.Int
	R *big.Int
	S *big.Int
}

Signature over a transaction, like how ethereum does it TODO: think about how the signature could be an object that wraps the base transaction. This might make content addressing a little bit simpler

type Transaction

type Transaction struct {
	To   Address // address of contract to invoke
	From Address

	Nonce uint64

	TickCost *big.Int
	Ticks    *big.Int
	Method   string
	Params   []interface{}

	Signature *Signature
}

Transaction is the equivalent of an ethereum transaction. But since ethereum transactions arent really transactions, theyre more just sending information from A to B, I (along with wanderer) want to call it a message. At the same time, we want to rename gas to ticks, since what the hell is gas anyways? TODO: ensure that transactions are not malleable *at all*, this is very important

func (*Transaction) Cid

func (tx *Transaction) Cid() (*cid.Cid, error)

TODO: we could control creation of transaction instances to guarantee this never errors. Pretty annoying to do though

func (*Transaction) Marshal

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

func (*Transaction) Unmarshal

func (tx *Transaction) Unmarshal(b []byte) error

type TransactionPool

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

func NewTransactionPool

func NewTransactionPool() *TransactionPool

func (*TransactionPool) Add

func (txp *TransactionPool) Add(tx *Transaction) error

func (*TransactionPool) ClearTx

func (txp *TransactionPool) ClearTx(c *cid.Cid)

func (*TransactionPool) GetBestTxs

func (txp *TransactionPool) GetBestTxs() []*Transaction

Jump to

Keyboard shortcuts

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