mock

package
v0.0.0-...-9a8596c Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBlock

func NewBlock(smesher *Smesher, layer *Layer) (*Block, *Activation)

Types

type Account

type Account struct {
	Address sm.Address // account public address
	Counter uint64     // aka nonce
	Balance Amount     // known account balance
	Active  bool
}

func (*Account) Export

func (account *Account) Export() *pb.Account

type Activation

type Activation struct {
	Id             ActivationID
	Layer          sm.LayerID   // the layer that this activation is part of
	SmesherId      SmesherID    // id of smesher who created the ATX
	Coinbase       sm.Address   // coinbase account id
	PrevAtx        ActivationID // previous ATX pointed to
	CommitmentSize uint64       // commitment size in bytes
}

func (*Activation) Export

func (atx *Activation) Export() *pb.Activation

type ActivationID

type ActivationID sm.ATXID

func (*ActivationID) Bytes

func (id *ActivationID) Bytes() []byte

type Amount

type Amount uint64

type Block

type Block struct {
	Id           sm.BlockID
	Transactions []*Transaction
}

func (*Block) Export

func (block *Block) Export() *pb.Block

type Config

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

type Epoch

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

type GasOffered

type GasOffered struct {
	GasProvided uint64
	GasPrice    uint64
}

func (*GasOffered) Export

func (gasOffered *GasOffered) Export() *pb.GasOffered

type Geo

type Geo struct {
	Name        string
	Coordinates [2]float64
}

type Layer

type Layer struct {
	Number        sm.LayerID
	Status        pb.Layer_LayerStatus
	Hash          []byte        // computer layer hash - do we need this?
	Blocks        []*Block      // layer's blocks
	Activations   []*Activation // list of layer's activations
	RootStateHash []byte        // when available - the root state hash of global state in this layer
	Transactions  map[sm.TransactionID]*Transaction
	Rewards       []*Reward
}

func (*Layer) Export

func (layer *Layer) Export() *pb.Layer

func (*Layer) GetTxsFee

func (layer *Layer) GetTxsFee() uint64

type Listener

type Listener interface {
	SetNetworkInfo(netId uint64, genesisTime uint64, epochNumLayers uint64, maxTransactionsPerSecond uint64, layerDuration uint64)
	OnLayerChanged(layer *pb.Layer)
	OnAccountChanged(account *pb.Account)
	OnReward(reward *pb.Reward)
	OnTransactionReceipt(receipt *pb.TransactionReceipt)
}

type Network

type Network struct {
	NetId                    uint64
	GenesisTime              uint64
	EpochNumLayers           uint64
	MaxTransactionsPerSecond uint64
	LayerDuration            uint64

	Smeshers     []*Smesher
	SmeshersById map[SmesherID]*Smesher

	Accounts            []*Account
	AccountsByAddress   map[sm.Address]*Account
	AccountsWithBalance map[sm.Address]*Account

	Epochs []*Epoch
	Layers []*Layer

	Listener Listener
	// contains filtered or unexported fields
}

func NewNetwork

func NewNetwork(listener Listener, netId int, epochLayers int, maxTxs int, layerDuration int) *Network

func (*Network) GetCurrentEpochNumber

func (n *Network) GetCurrentEpochNumber() uint64

func (*Network) GetCurrentLayerNumber

func (n *Network) GetCurrentLayerNumber() uint64

func (*Network) Tick

func (n *Network) Tick()

type Rate

type Rate struct {
	Value int
	Rate  int
}

type Reward

type Reward struct {
	Layer         sm.LayerID
	Total         Amount
	LayerReward   Amount
	LayerComputed sm.LayerID // layer number of the layer when reward was computed
	// tx_fee = total - layer_reward
	Coinbase sm.Address // account awarded this reward
	Smesher  SmesherID  // it will be nice to always have this in reward events
}

func (*Reward) Export

func (reward *Reward) Export() *pb.Reward

type Signature

type Signature struct {
	Scheme    pb.Signature_Scheme // the signature's scheme
	Signature []byte              // the signature itself
	PublicKey []byte              // included in schemes which require signer to provide a public key
}

func (*Signature) Export

func (signature *Signature) Export() *pb.Signature

type Smesher

type Smesher struct {
	Id             SmesherID
	Geo            Geo
	Activations    []*Activation
	CommitmentSize uint64 // commitment size in bytes
	Accounts       []Account
	Active         bool
}

func NewSmesher

func NewSmesher() *Smesher

func (*Smesher) GetAccount

func (s *Smesher) GetAccount() *Account

type SmesherID

type SmesherID [32]byte

func (*SmesherID) Bytes

func (id *SmesherID) Bytes() []byte

type Transaction

type Transaction struct {
	Id sm.TransactionID

	Sender     sm.Address // tx originator, should match signer inside Signature
	GasOffered GasOffered // gas price and max gas offered
	Amount     Amount     // amount of coin transfered in this tx by sender
	Counter    uint64     // tx counter aka nonce
	Signature  Signature  // sender signature on transaction

	State   pb.TransactionState_TransactionState
	Receipt *TransactionReceipt

	IsSimple bool

	// CoinTransferTransaction
	Receiver sm.Address

	// SmartContractTransaction
	Type    pb.SmartContractTransaction_TransactionType
	Data    []byte     // packed binary arguments, including ABI selector
	Address sm.Address // address of smart contract or template
}

func NewCoinTransferTransaction

func NewCoinTransferTransaction(from *Account, to *Account) *Transaction

func (*Transaction) Export

func (tx *Transaction) Export() *pb.Transaction

type TransactionFee

type TransactionFee struct {
	GasConsumed uint64
	GasPrice    uint64
}

type TransactionReceipt

type TransactionReceipt struct {
	Id sm.TransactionID // the source transaction
	// The results of STF transaction processing
	Result      pb.TransactionReceipt_TransactionResult
	GasUsed     uint64     // gas units used by the transaction (gas price in tx)
	Fee         Amount     // transaction fee charged for the transaction
	LayerNumber sm.LayerID // The layer in which the STF processed this transaction
	Index       uint32     // the index of the tx in the ordered list of txs to be executed by stf in the layer
	AppAddress  sm.Address // deployed app address or code template address
}

Jump to

Keyboard shortcuts

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