model

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTransactionStateFromResult

func GetTransactionStateFromResult(txResult int) int

func IsApprovedLayer

func IsApprovedLayer(l *pb.Layer) bool

func IsConfirmedLayer

func IsConfirmedLayer(l *pb.Layer) bool

func NewLayer

func NewLayer(in *pb.Layer, networkInfo *NetworkInfo) (*Layer, []*Block, []*Activation, map[string]*Transaction)

func ToCheckedAddress added in v0.0.6

func ToCheckedAddress(a string) string

Hex returns an EIP55-compliant hex string representation of the address.

Types

type Account

type Account struct {
	Address   string // account public address
	Balance   uint64 // known account balance
	Sent      uint64
	Received  uint64
	Awards    uint64
	Fees      uint64
	Timestamp uint32
	Counter   uint64
}

func NewAccount

func NewAccount(in *pb.Account) *Account

type AccountService

type AccountService interface {
	GetAccount(ctx context.Context, query *bson.D) (*Account, error)
	GetAccounts(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*Account, error)
	SaveAccount(ctx context.Context, in *Account) error
}

type Activation

type Activation struct {
	Id             string
	Layer          uint32 // the layer that this activation is part of
	SmesherId      string // id of smesher who created the ATX
	Coinbase       string // coinbase account id
	PrevAtx        string // previous ATX pointed to
	CommitmentSize uint64 // commitment size in bytes
	Timestamp      uint32
}

func NewActivation

func NewActivation(atx *pb.Activation, timestamp uint32) *Activation

func (*Activation) GetSmesher

func (atx *Activation) GetSmesher() *Smesher

type ActivationService

type ActivationService interface {
	GetActivation(ctx context.Context, query *bson.D) (*Activation, error)
	GetActivations(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*Activation, error)
	SaveActivation(ctx context.Context, in *Activation) error
}

type App

type App struct {
	Address string
}

type AppService

type AppService interface {
	GetAccount(ctx context.Context, query *bson.D) (*App, error)
	GetApps(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*App, error)
	SaveApp(ctx context.Context, in *App) error
}

type Block

type Block struct {
	Id        string
	Layer     uint32
	Epoch     uint32
	Start     uint32
	End       uint32
	TxsNumber uint32
	TxsValue  uint64
}

type BlockService

type BlockService interface {
	GetBlock(ctx context.Context, query *bson.D) (*Block, error)
	GetBlocks(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*Block, error)
	SaveBlock(ctx context.Context, in *Block) error
}

type Epoch

type Epoch struct {
	Number     int32
	Start      uint32
	End        uint32
	LayerStart uint32
	LayerEnd   uint32
	Layers     uint32
	Stats      Stats
}

type EpochService

type EpochService interface {
	GetEpoch(ctx context.Context, query *bson.D) (*Epoch, error)
	GetEpochs(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*Epoch, error)
	SaveEpoch(ctx context.Context, in *Epoch) error
}

type Geo

type Geo struct {
	Name        string     `json:"name"`
	Coordinates [2]float64 `json:"coordinates"`
}

type Layer

type Layer struct {
	Number       uint32
	Status       int
	Txs          uint32
	Start        uint32
	End          uint32
	TxsAmount    uint64
	AtxCSize     uint64
	Rewards      uint64
	Epoch        uint32
	Smeshers     uint32
	Hash         string
	BlocksNumber uint32
}

type LayerService

type LayerService interface {
	GetLayer(ctx context.Context, query *bson.D) (*Layer, error)
	GetLayers(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*Layer, error)
	SaveLayer(ctx context.Context, in *Layer) error
}

type NetworkInfo

type NetworkInfo struct {
	NetId                    uint32
	GenesisTime              uint32
	EpochNumLayers           uint32
	MaxTransactionsPerSecond uint32
	LayerDuration            uint32

	LastLayer          uint32
	LastLayerTimestamp uint32
	LastApprovedLayer  uint32
	LastConfirmedLayer uint32

	ConnectedPeers uint64
	IsSynced       bool
	SyncedLayer    uint32
	TopLayer       uint32
	VerifiedLayer  uint32
}

type Reward

type Reward struct {
	Layer         uint32
	Total         uint64
	LayerReward   uint64
	LayerComputed uint32 // layer number of the layer when reward was computed
	// tx_fee = total - layer_reward
	Coinbase  string // account awarded this reward
	Smesher   string // it will be nice to always have this in reward events
	Space     uint64
	Timestamp uint32
}

func NewReward

func NewReward(reward *pb.Reward) *Reward

type RewardService

type RewardService interface {
	GetReward(ctx context.Context, query *bson.D) (*Reward, error)
	GetRewards(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*Reward, error)
	SaveReward(ctx context.Context, in *Reward) error
}

type Smesher

type Smesher struct {
	Id             string
	Geo            Geo
	CommitmentSize uint64 // commitment size in bytes
	Coinbase       string
	AtxCount       uint32
	Timestamp      uint32
}

type SmesherService

type SmesherService interface {
	GetSmesher(ctx context.Context, query *bson.D) (*Smesher, error)
	GetSmeshers(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*Smesher, error)
	SaveSmesher(ctx context.Context, in *Smesher) error
}

type Statistics

type Statistics struct {
	Capacity      int64 // Average tx/s rate over capacity considering all layers in the current epoch.
	Decentral     int64 // Distribution of storage between all active smeshers.
	Smeshers      int64 // Number of active smeshers in the current epoch.
	Transactions  int64 // Total number of transactions processed by the state transition function.
	Accounts      int64 // Total number of on-mesh accounts with a non-zero coin balance as of the current epoch.
	Circulation   int64 // Total number of Smesh coins in circulation. This is the total balances of all on-mesh accounts.
	Rewards       int64 // Total amount of Smesh minted as mining rewards as of the last known reward distribution event.
	RewardsNumber int64
	Security      int64 // Total amount of storage committed to the network based on the ATXs in the previous epoch.
	TxsAmount     int64 // Total amount of coin transferred between accounts in the epoch. Incl coin transactions and smart wallet transactions.
}

type Stats

type Stats struct {
	Current    Statistics
	Cumulative Statistics
}

type Transaction

type Transaction struct {
	Id string

	Layer      uint32
	Block      string
	BlockIndex uint32
	Index      uint32 // the index of the tx in the ordered list of txs to be executed by stf in the layer
	State      int
	Timestamp  uint32

	GasProvided uint64
	GasPrice    uint64
	GasUsed     uint64 // gas units used by the transaction (gas price in tx)
	Fee         uint64 // transaction fee charged for the transaction

	Amount  uint64 // amount of coin transfered in this tx by sender
	Counter uint64 // tx counter aka nonce

	Type      int
	Scheme    int    // the signature's scheme
	Signature string // the signature itself
	PublicKey string // included in schemes which require signer to provide a public key

	Sender   string // tx originator, should match signer inside Signature
	Receiver string
	SvmData  string // svm binary data. Decode with svm-codec
}

func NewTransaction

func NewTransaction(in *pb.Transaction, layer uint32, blockId string, timestamp uint32, blockIndex uint32) *Transaction

type TransactionReceipt

type TransactionReceipt struct {
	Id      string
	Layer   uint32
	Index   uint32 // the index of the tx in the ordered list of txs to be executed by stf in the layer
	Result  int
	GasUsed uint64 // gas units used by the transaction (gas price in tx)
	Fee     uint64 // transaction fee charged for the transaction
	SvmData string // svm binary data. Decode with svm-codec
}

func NewTransactionReceipt

func NewTransactionReceipt(txReceipt *pb.TransactionReceipt) *TransactionReceipt

type TransactionService

type TransactionService interface {
	GetTransaction(ctx context.Context, query *bson.D) (*Transaction, error)
	GetTransactions(ctx context.Context, query *bson.D, opts ...*options.FindOptions) ([]*Transaction, error)
	SaveTransaction(ctx context.Context, in *Transaction) error
}

Jump to

Keyboard shortcuts

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