models

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const RewardEvent = "noah/RewardEvent"
View Source
const SlashEvent = "noah/SlashEvent"
View Source
const TxTypeBuyCoin = 4
View Source
const TxTypeCreateCoin = 5
View Source
const TxTypeDeclareCandidacy = 6
View Source
const TxTypeDelegate = 7
View Source
const TxTypeEditCandidate = 14
View Source
const TxTypeMultiSend = 13
View Source
const TxTypeMultiSig = 12
View Source
const TxTypeRedeemCheck = 9
View Source
const TxTypeSellAllCoin = 3
View Source
const TxTypeSellCoin = 2
View Source
const TxTypeSend = 1
View Source
const TxTypeSetCandidateOffline = 11
View Source
const TxTypeSetCandidateOnline = 10
View Source
const TxTypeUnbound = 8
View Source
const ValidatorStatusNotReady = 1
View Source
const ValidatorStatusReady = 2

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	ID                  uint64                `json:"id" sql:",pk"`
	Address             string                `json:"address" sql:",unique; type:varchar(64)"`
	UpdatedAtBlockId    uint64                `json:"updated_at_block_id"`
	UpdatedAt           time.Time             `json:"updated_at"`
	Balances            []*Balance            `json:"balances"`                                     //relation has many to Balances
	Rewards             []*Reward             `json:"rewards"`                                      //relation has many to Rewards
	Slashes             []*Slash              `json:"slashes"`                                      //relation has many to Slashes
	Transactions        []*Transaction        `json:"transactions" pg:"fk:from_address_id"`         //relation has many to Transactions
	InvalidTransactions []*InvalidTransaction `json:"invalid_transactions" pg:"fk:from_address_id"` //relation has many to InvalidTransactions
	CreatedAt           time.Time             `json:"created_at"`
}

func (*Address) GetAddress

func (a *Address) GetAddress() string

Return address with prefix

type AggregatedReward

type AggregatedReward struct {
	FromBlockID uint64     `json:"from_block_id" sql:",pk"`
	ToBlockID   uint64     `json:"to_block_id"`
	AddressID   uint64     `json:"address_id"    sql:",pk"`
	ValidatorID uint64     `json:"validator_id"  sql:",pk"`
	Role        string     `json:"role"          sql:",pk"`
	Amount      string     `json:"amount"        sql:"type:numeric(70)"`
	TimeID      time.Time  `json:"time_id"`
	FromBlock   *Block     //Relation has one to Blocks
	ToBlock     *Block     //Relation has one to Blocks
	Address     *Address   //Relation has one to Addresses
	Validator   *Validator //Relation has one to Validators
}

type Balance

type Balance struct {
	ID        uint64    `json:"id" sql:",pk"`
	AddressID uint64    `json:"address_id"`
	CoinID    uint64    `json:"coin_id"`
	Value     string    `json:"value" sql:"type:numeric(70)"`
	CreatedAt time.Time `json:"created_at"`
	Address   *Address  //Relation has one to Address
	Coin      *Coin     //Relation has one to Coin
}

type Block

type Block struct {
	ID                  uint64                `json:"id" sql:",pk"`
	TotalTxs            uint64                `json:"total_txs" sql:"default:0"`
	Size                uint64                `json:"size"`
	ProposerValidatorID uint64                `json:"proposer_validator_id"`
	NumTxs              uint32                `json:"num_txs" sql:"default:0"`
	BlockTime           uint64                `json:"block_time"`
	CreatedAt           time.Time             `json:"created_at"`
	UpdatedAt           time.Time             `json:"updated_at"`
	BlockReward         string                `json:"block_reward" sql:"type:numeric(70)"`
	Hash                string                `json:"hash"`
	Proposer            *Validator            `json:"proposer" pg:"fk:proposer_validator_id"`    //relation has one to Validators
	Validators          []*Validator          `json:"validators" pg:"many2many:block_validator"` //relation has many to Validators
	Transactions        []*Transaction        `json:"transactions"`                              //relation has many to Transactions
	InvalidTransactions []*InvalidTransaction `json:"invalid_transactions"`                      //relation has many to InvalidTransactions
	Rewards             []*Reward             `json:"rewards"`                                   //relation has many to Rewards
	Slashes             []*Slash              `json:"slashes"`                                   //relation has many to Slashes
	BlockValidators     []BlockValidator      `json:"block_validators"`
}

func (*Block) GetHash

func (t *Block) GetHash() string

Return block hash with prefix

type BlockAddresses

type BlockAddresses struct {
	Height    uint64
	Addresses []string
}

type BlockValidator

type BlockValidator struct {
	BlockID     uint64    `json:"block_id"`
	ValidatorID uint64    `json:"validator_id"`
	CreatedAt   time.Time `json:"created_at"`
	Signed      bool      `json:"signed"`
	Validator   Validator `json:"validator"`
	// contains filtered or unexported fields
}

type BlockValidators

type BlockValidators struct {
	Height     uint64
	Validators []*Validator
}

type BuyCoinTxData

type BuyCoinTxData struct {
	CoinToBuy          string `json:"coin_to_buy"`
	ValueToBuy         string `json:"value_to_buy"`
	CoinToSell         string `json:"coin_to_sell"`
	MaximumValueToSell string `json:"maximum_value_to_sell"`
}

type Coin

type Coin struct {
	ID                    uint64     `json:"id" sql:",pk"`
	CreationAddressID     *uint64    `json:"creation_address_id"`
	CreationTransactionID *uint64    `json:"creation_transaction_id"`
	Crr                   uint64     `json:"crr"`
	Volume                string     `json:"volume"          sql:"type:numeric(70)"`
	ReserveBalance        string     `json:"reserve_balance" sql:"type:numeric(70)"`
	Price                 string     `json:"price"           sql:"type:numeric(100)"`
	Capitalization        string     `json:"capitalization"  sql:"type:numeric(100)"`
	Delegated             uint64     `json:"delegated"`
	StartVolume           string     `json:"start_volume"          sql:"type:numeric(70)"`
	StartReserveBalance   string     `json:"start_reserve_balance" sql:"type:numeric(70)"`
	StartPrice            string     `json:"start_price"           sql:"type:numeric(100)"`
	Name                  string     `json:"name"            sql:"type:varchar(255)"`
	Symbol                string     `json:"symbol"          sql:"type:varchar(20)"`
	CreatedAt             time.Time  `json:"created_at"`
	UpdatedAt             time.Time  `json:"updated_at"`
	DeletedAt             *time.Time `json:"deleted_at"      pg:",soft_delete"`
	Description           string     `json:"description"     sql:"type:varchar(1024)"`
	IconURL               string     `json:"icon_url"        sql:"type:varchar(255)"`

	Address string `json:"address" sql:"-"`
}

func (Coin) GetAddress added in v0.1.2

func (c Coin) GetAddress() string

type CreateCoinTxData

type CreateCoinTxData struct {
	Name                 string `json:"name"`
	Symbol               string `json:"symbol"`
	InitialAmount        string `json:"initial_amount"`
	InitialReserve       string `json:"initial_reserve"`
	ConstantReserveRatio string `json:"constant_reserve_ratio"`
}

type CreateMultisigTxData

type CreateMultisigTxData struct {
	Threshold string   `json:"threshold"`
	Weights   []string `json:"weights"`
	Addresses []string `json:"addresses"`
}

type DeclareCandidacyTxData

type DeclareCandidacyTxData struct {
	Address    string `json:"address"`
	PubKey     string `json:"pub_key"`
	Commission string `json:"commission"`
	Coin       string `json:"coin"`
	Stake      string `json:"stake"`
}

type DelegateTxData

type DelegateTxData struct {
	PubKey string `json:"pub_key"`
	Coin   string `json:"coin"`
	Value  string `json:"value"`
}

type EditCandidateTxData

type EditCandidateTxData struct {
	PubKey        string `json:"pub_key"`
	RewardAddress string `json:"reward_address"`
	OwnerAddress  string `json:"owner_address"`
}

type ExtenderEnvironment

type ExtenderEnvironment struct {
	// todo wsLink
	AppName                         string
	BaseCoin                        string
	CoinsUpdateTime                 int
	Debug                           bool
	DbName                          string
	DbUser                          string
	DbPassword                      string
	DbHost                          string
	DbPort                          int
	DbMinIdleConns                  int
	DbPoolSize                      int
	WsHost                          string
	WsPort                          int
	WsKey                           string
	NodeApi                         string
	ApiHost                         string
	ApiPort                         int
	TxChunkSize                     int
	AddrChunkSize                   int
	EventsChunkSize                 int
	StakeChunkSize                  int
	WrkSaveRewardsCount             int
	WrkSaveSlashesCount             int
	WrkSaveTxsCount                 int
	WrkSaveTxsOutputCount           int
	WrkSaveInvTxsCount              int
	WrkSaveAddressesCount           int
	WrkSaveValidatorTxsCount        int
	WrkUpdateBalanceCount           int
	WrkGetBalancesFromNodeCount     int
	WrkUpdateTxsIndexNumBlocks      int
	WrkUpdateTxsIndexTime           int
	RewardAggregateEveryBlocksCount int
	RewardAggregateTimeInterval     string
	NatsClusterID                   string
	NatsAddr                        string
}

type InvalidTransaction

type InvalidTransaction struct {
	ID            uint64    `json:"id" sql:",pk"`
	FromAddressID uint64    `json:"from_address_id"`
	BlockID       uint64    `json:"block_id"`
	CreatedAt     time.Time `json:"created_at"`
	Type          uint8     `json:"type"`
	Hash          string    `json:"hash"`
	TxData        string    `json:"tx_data" sql:",jsonb"`
	Block         *Block    //Relation has one to Blocks
	FromAddress   *Address  `pg:"fk:from_address_id"` //Relation has one to Addresses
}

func (InvalidTransaction) GetHash

func (t InvalidTransaction) GetHash() string

Return transactions hash with prefix

type MultiSendTxData

type MultiSendTxData struct {
	List []SendTxData `json:"list"`
}

type RedeemCheckTxData

type RedeemCheckTxData struct {
	RawCheck string `json:"raw_check"`
	Proof    string `json:"proof"`
}

type Reward

type Reward struct {
	BlockID     uint64     `json:"block"        sql:",pk"`
	AddressID   uint64     `json:"address_id"   sql:",pk"`
	ValidatorID uint64     `json:"validator_id" sql:",pk"`
	Role        string     `json:"role"         sql:",pk"`
	Amount      string     `json:"amount"       sql:"type:numeric(70)"`
	CreatedAt   time.Time  `json:"created_at"`
	Block       *Block     //Relation has one to Blocks
	Address     *Address   //Relation has one to Addresses
	Validator   *Validator //Relation has one to Validators
}

type SellAllCoinTxData

type SellAllCoinTxData struct {
	CoinToSell        string `json:"coin_to_sell"`
	CoinToBuy         string `json:"coin_to_buy"`
	MinimumValueToBuy string `json:"minimum_value_to_buy"`
}

type SellCoinTxData

type SellCoinTxData struct {
	CoinToSell        string `json:"coin_to_sell"`
	ValueToSell       string `json:"value_to_sell"`
	CoinToBuy         string `json:"coin_to_buy"`
	MinimumValueToBuy string `json:"minimum_value_to_buy"`
}

type SendTxData

type SendTxData struct {
	Coin  string `json:"coin"`
	To    string `json:"to"`
	Value string `json:"value"`
}

type SetCandidateTxData

type SetCandidateTxData struct {
	PubKey string `json:"pub_key"`
}

type Slash

type Slash struct {
	ID          uint64     `json:"id" sql:",pk"`
	CoinID      uint64     `json:"coin_id"`
	BlockID     uint64     `json:"block_id"`
	AddressID   uint64     `json:"address_id"`
	ValidatorID uint64     `json:"validator_id"`
	Amount      string     `json:"amount" sql:"type:numeric(70)"`
	CreatedAt   time.Time  `json:"created_at"`
	Coin        *Coin      //Relation has one to Coins
	Block       *Block     //Relation has one to Blocks
	Address     *Address   //Relation has one to Addresses
	Validator   *Validator //Relation has one to Validators
}

type Stake

type Stake struct {
	ID             uint64     `json:"id" sql:",pk"`
	OwnerAddressID uint64     `json:"owner_address_id"`
	ValidatorID    uint64     `json:"validator_id"`
	CoinID         uint64     `json:"coin_id"`
	Value          string     `json:"value"     sql:"type:numeric(70)"`
	NoahValue      string     `json:"noah_value" sql:"type:numeric(70)"`
	CreatedAt      time.Time  `json:"created_at"`
	Coin           *Coin      `json:"coins"`                                  //Relation has one to Coins
	OwnerAddress   *Address   `json:"owner_address" pg:"fk:owner_address_id"` //Relation has one to Addresses
	Validator      *Validator `json:"validator"`                              //Relation has one to Validators
}

type Transaction

type Transaction struct {
	ID            uint64               `json:"id" sql:",pk"`
	FromAddressID uint64               `json:"from_address_id"`
	Nonce         uint64               `json:"nonce"`
	GasPrice      uint64               `json:"gas_price"`
	Gas           uint64               `json:"gas"`
	BlockID       uint64               `json:"block_id"`
	GasCoinID     uint64               `json:"gas_coin_id"`
	CreatedAt     time.Time            `json:"created_at"`
	Type          uint8                `json:"type"`
	Hash          string               `json:"hash"`
	ServiceData   string               `json:"service_data"`
	Data          json.RawMessage      `json:"data"`
	IData         interface{}          `json:"-" sql:"-"`
	Tags          map[string]string    `json:"tags"`
	Payload       []byte               `json:"payload"`
	RawTx         []byte               `json:"raw_tx"`
	Block         *Block               `json:"block"`                                             //Relation has one to Blocks
	FromAddress   *Address             `json:"from_address" pg:"fk:from_address_id"`              //Relation has one to Address
	GasCoin       *Coin                `json:"gas_coin"     pg:"fk:gas_coin_id"`                  //Relation has one to Coin
	Validators    []*Validator         `json:"validators"   pg:"many2many:transaction_validator"` //Relation has many to Validators
	TxOutputs     []*TransactionOutput `json:"tx_outputs"`
	TxOutput      *TransactionOutput   `json:"tx_output"`
}

func (*Transaction) GetFee

func (t *Transaction) GetFee() uint64

Return fee for transaction

func (*Transaction) GetHash

func (t *Transaction) GetHash() string

Return transactions hash with prefix

type TransactionOutput

type TransactionOutput struct {
	ID            uint64       `json:"id"`
	TransactionID uint64       `json:"transaction_id"`
	ToAddressID   uint64       `json:"to_address_id"`
	CoinID        uint64       `json:"coin_id"`
	Value         string       `json:"value" sql:"type:numeric(70)"`
	CreatedAt     time.Time    `json:"created_at"`
	Coin          *Coin        `json:"coin"`                             //Relation has one to Coins
	ToAddress     *Address     `json:"to_address" pg:"fk:to_address_id"` //Relation has one to Addresses
	Transaction   *Transaction `json:"transaction"`                      //Relation has one to Transactions
}

type TransactionValidator

type TransactionValidator struct {
	TransactionID uint64
	ValidatorID   uint64
	// contains filtered or unexported fields
}

type UnbondTxData

type UnbondTxData struct {
	PubKey string `json:"pub_key"`
	Coin   string `json:"coin"`
	Value  string `json:"value"`
}

type Validator

type Validator struct {
	ID                   uint64     `json:"id" sql:",pk"`
	RewardAddressID      *uint64    `json:"reward_address_id"`
	OwnerAddressID       *uint64    `json:"owner_address_id"`
	CreatedAtBlockID     *uint64    `json:"created_at_block_id"`
	Status               *uint8     `json:"status"`
	Commission           *uint64    `json:"commission"`
	TotalStake           *string    `json:"total_stake" sql:"type:numeric(70)"`
	PublicKey            string     `json:"public_key"  sql:"type:varchar(70)"`
	Name                 *string    `json:"name"`
	SiteUrl              *string    `json:"site_url"`
	IconUrl              *string    `json:"icon_url"`
	Description          *string    `json:"description"`
	MetaUpdatedAtBlockID *uint64    `json:"meta_updated_at_block_id"`
	UpdatedAt            *time.Time `json:"updated_at"`
	RewardAddress        *Address   `json:"reward_address" pg:"fk:reward_address_id"`
	OwnerAddress         *Address   `json:"owner_address"  pg:"fk:owner_address_id"`
	Stakes               []*Stake   `json:"stakes"`
	Uptime               *float64   `json:"uptime"`
	CreatedAt            time.Time  `json:"created_at"`
	CountDelegators      *uint64    `json:"count_delegators"`
}

func (Validator) GetPublicKey

func (v Validator) GetPublicKey() string

Return validatyors PK with prefix

Jump to

Keyboard shortcuts

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