data

package
Version: v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: GPL-3.0 Imports: 34 Imported by: 4

Documentation

Index

Constants

View Source
const (
	JobUser           = "user"
	JobBillingChecker = "billing_checker"
	JobBCMonitor      = "bc_monitor"
	JobTask           = "task"
	JobServiceAdapter = "service_adapter"
	JobSessionServer  = "session_server"
)

Job creators.

View Source
const (
	JobActive   = "active"
	JobDone     = "done"
	JobFailed   = "failed"
	JobCanceled = "canceled"
)

Job statuses.

View Source
const (
	JobOffering    = "offering"
	JobChannel     = "channel"
	JobEndpoint    = "endpoint"
	JobAccount     = "account"
	JobTransaction = "transaction"
)

Job related object types.

View Source
const (
	JobClientPreChannelCreate               = "clientPreChannelCreate"
	JobClientAfterChannelCreate             = "clientAfterChannelCreate"
	JobClientPreChannelTopUp                = "clientPreChannelTopUp"
	JobClientAfterChannelTopUp              = "clientAfterChannelTopUp"
	JobClientPreUncooperativeCloseRequest   = "clientPreUncooperativeCloseRequest"
	JobClientAfterUncooperativeCloseRequest = "clientAfterUncooperativeCloseRequest"
	JobClientPreUncooperativeClose          = "clientPreUncooperativeClose"
	JobClientAfterUncooperativeClose        = "clientAfterUncooperativeClose"
	JobClientAfterCooperativeClose          = "clientAfterCooperativeClose"
	JobClientPreServiceSuspend              = "clientPreServiceSuspend"
	JobClientPreServiceUnsuspend            = "clientPreServiceUnsuspend"
	JobClientPreServiceTerminate            = "clientPreServiceTerminate"
	JobClientEndpointGet                    = "clientEndpointGet"
	JobClientAfterOfferingMsgBCPublish      = "clientAfterOfferingMsgBCPublish"
	JobClientAfterOfferingPopUp             = "clientAfterOfferingPopUp"
	JobClientAfterOfferingDelete            = "clientAfterOfferingDelete"
	JobClientRecordClosing                  = "clientRecordClosing"
	JobAgentAfterChannelCreate              = "agentAfterChannelCreate"
	JobAgentAfterChannelTopUp               = "agentAfterChannelTopUp"
	JobAgentAfterUncooperativeCloseRequest  = "agentAfterUncooperativeCloseRequest"
	JobAgentAfterUncooperativeClose         = "agentAfterUncooperativeClose"
	JobAgentAfterCooperativeClose           = "agentAfterCooperativeClose"
	JobAgentPreServiceSuspend               = "agentPreServiceSuspend"
	JobAgentPreServiceUnsuspend             = "agentPreServiceUnsuspend"
	JobAgentPreServiceTerminate             = "agentPreServiceTerminate"
	JobAgentPreEndpointMsgCreate            = "agentPreEndpointMsgCreate"
	JobAgentPreOfferingMsgBCPublish         = "agentPreOfferingMsgBCPublish"
	JobAgentAfterOfferingMsgBCPublish       = "agentAfterOfferingMsgBCPublish"
	JobAgentPreOfferingDelete               = "agentPreOfferingDelete"
	JobAgentPreOfferingPopUp                = "agentPreOfferingPopUp"
	JobAgentAfterOfferingPopUp              = "agentAfterOfferingPopUp"
	JobAgentAfterOfferingDelete             = "agentAfterOfferingDelete"
	JobPreAccountAddBalanceApprove          = "preAccountAddBalanceApprove"
	JobAfterAccountAddBalanceApprove        = "afterAccountAddBalanceApprove"
	JobPreAccountAddBalance                 = "preAccountAddBalance"
	JobAfterAccountAddBalance               = "afterAccountAddBalance"
	JobPreAccountReturnBalance              = "preAccountReturnBalance"
	JobAfterAccountReturnBalance            = "afterAccountReturnBalance"
	JobAccountUpdateBalances                = "accountUpdateBalances"
	JobCompleteServiceTransition            = "completeServiceTransition"
	JobDecrementCurrentSupply               = "decrementCurrentSupply"
	JobIncrementCurrentSupply               = "incrementCurrentSupply"
	JobIncreaseTxGasPrice                   = "increaseTxGasPrice"
)

Job types.

View Source
const (
	RoleAgent  = "agent"
	RoleClient = "client"
)

Possible user roles.

View Source
const (
	TemplateOffer  = "offer"
	TemplateAccess = "access"
)

Templates kinds.

View Source
const (
	ProductUsageIncremental = "incremental"
	ProductUsageTotal       = "total"
)

Product usage reporting types.

View Source
const (
	UnitScalar  = "units"
	UnitSeconds = "seconds"
)

Unit used for billing calculation.

View Source
const (
	BillingPrepaid  = "prepaid"
	BillingPostpaid = "postpaid"
)

Billing types.

View Source
const (
	OfferEmpty       = "empty"
	OfferPoppingUp   = "popping_up"
	OfferPoppedUp    = "popped_up"
	OfferRegistering = "registering"
	OfferRegistered  = "registered"
	OfferRemoving    = "removing"
	OfferRemoved     = "removed"
)

Offering statuses.

View Source
const (
	OfferingResidential = "residential"
	OfferingDatacenter  = "datacenter"
	OfferingMobile      = "mobile"
)

Offering ip types.

View Source
const (
	ChannelPending       = "pending"
	ChannelActive        = "active"
	ChannelWaitCoop      = "wait_coop"
	ChannelClosedCoop    = "closed_coop"
	ChannelWaitChallenge = "wait_challenge"
	ChannelInChallenge   = "in_challenge"
	ChannelWaitUncoop    = "wait_uncoop"
	ChannelClosedUncoop  = "closed_uncoop"
)

State channel statuses.

View Source
const (
	ServicePending     = "pending"
	ServiceActivating  = "activating"
	ServiceActive      = "active"
	ServiceSuspending  = "suspending"
	ServiceSuspended   = "suspended"
	ServiceTerminating = "terminating"
	ServiceTerminated  = "terminated"
)

Service operational statuses.

View Source
const (
	ContractPTC = "ptc"
	ContractPSC = "psc"
)

Contract types.

View Source
const (
	AccessDenied = iota
	ReadOnly
	ReadWrite
)

Permissions for settings.

View Source
const (
	CountryStatusUnknown = "unknown"
	CountryStatusValid   = "valid"
	CountryStatusInvalid = "invalid"
)

Country statuses.

View Source
const (
	TxUnsent = "unsent"
	TxSent   = "sent"
	TxMined  = "mined"
	TxUncle  = "uncle"
)

Transaction statuses.

View Source
const (
	ClosingCoop   = "coop"
	ClosingUncoop = "uncoop"
)

Closing types. (Closings are used in rating calculation).

View Source
const (
	SettingBlockLimit                       = "eth.event.blocklimit"
	SettingOfferingsFreshBlocks             = "eth.event.offeringsfreshblocks"
	SettingOfferingAutoPopUp                = "offering.autopopup"
	SettingLastProcessedBlock               = "eth.event.lastProcessedBlock"
	SettingLastBackSearchBlock              = "eth.event.lastBackSearchBlock"
	SettingClientMonitoringStartBlock       = "eth.event.clientMonitoringStartBlock"
	SettingMinConfirmations                 = "eth.min.confirmations"
	SettingPasswordHash                     = "system.password"
	SettingPasswordSalt                     = "system.salt"
	SettingsPeriodChallange                 = "psc.periods.challenge"
	SettingsPeriodPopUp                     = "psc.periods.popup"
	SettingsPeriodRemove                    = "psc.periods.remove"
	SettingGUI                              = "system.gui"
	SettingClientMinDeposit                 = "client.min.deposit"
	SettingClientAutoincreaseDepositPercent = "client.autoincrease.percent"
	SettingClientAutoincreaseDeposit        = "client.autoincrease.deposit"
	SettingRatingRankingSteps               = "rating.ranking.steps"
)

Setting keys.

View Source
const (
	TestPassword     = "secret"
	TestPasswordHash = "JDJhJDEwJHNVbWNtTkVwQk5DMkwuOC5OL1BXU08uYkJMMkxjcmthTW1BZklOTUNjNWZDdWNUOU54Tzlp"
	TestSalt         = 6012867121110302348
)

Test authentication constants.

View Source
const (
	ClientIdentByChannelID = "by_channel_id"
)

Product authentication types.

View Source
const (
	OfferingSOMCTor uint8 = 1 + iota
)

Comminication types.

View Source
const (
	TestServiceEndpointAddress = "localhost"
)

Test service addresses.

Variables

View Source
var AccountTable = &accountTableType{
	s: parse.StructInfo{Type: "Account", SQLSchema: "", SQLName: "accounts", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "EthAddr", Type: "HexString", Column: "eth_addr"}, {Name: "PublicKey", Type: "Base64String", Column: "public_key"}, {Name: "PrivateKey", Type: "Base64String", Column: "private_key"}, {Name: "IsDefault", Type: "bool", Column: "is_default"}, {Name: "InUse", Type: "bool", Column: "in_use"}, {Name: "Name", Type: "string", Column: "name"}, {Name: "PTCBalance", Type: "uint64", Column: "ptc_balance"}, {Name: "PSCBalance", Type: "uint64", Column: "psc_balance"}, {Name: "EthBalance", Type: "Base64BigInt", Column: "eth_balance"}, {Name: "LastBalanceCheck", Type: "*time.Time", Column: "last_balance_check"}}, PKFieldIndex: 0},
	z: new(Account).Values(),
}

AccountTable represents accounts view or table in SQL database.

View Source
var ChannelTable = &channelTableType{
	s: parse.StructInfo{Type: "Channel", SQLSchema: "", SQLName: "channels", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "Agent", Type: "HexString", Column: "agent"}, {Name: "Client", Type: "HexString", Column: "client"}, {Name: "Offering", Type: "string", Column: "offering"}, {Name: "Block", Type: "uint32", Column: "block"}, {Name: "ChannelStatus", Type: "string", Column: "channel_status"}, {Name: "ServiceStatus", Type: "string", Column: "service_status"}, {Name: "ServiceChangedTime", Type: "*time.Time", Column: "service_changed_time"}, {Name: "PreparedAt", Type: "time.Time", Column: "prepared_at"}, {Name: "TotalDeposit", Type: "uint64", Column: "total_deposit"}, {Name: "Salt", Type: "uint64", Column: "salt"}, {Name: "Username", Type: "*string", Column: "username"}, {Name: "Password", Type: "Base64String", Column: "password"}, {Name: "ReceiptBalance", Type: "uint64", Column: "receipt_balance"}, {Name: "ReceiptSignature", Type: "*Base64String", Column: "receipt_signature"}}, PKFieldIndex: 0},
	z: new(Channel).Values(),
}

ChannelTable represents channels view or table in SQL database.

View Source
var ClosingTable = &closingTableType{
	s: parse.StructInfo{Type: "Closing", SQLSchema: "", SQLName: "closings", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "Type", Type: "string", Column: "type"}, {Name: "Agent", Type: "HexString", Column: "agent"}, {Name: "Client", Type: "HexString", Column: "client"}, {Name: "Balance", Type: "uint64", Column: "balance"}, {Name: "Block", Type: "uint32", Column: "block"}}, PKFieldIndex: 0},
	z: new(Closing).Values(),
}

ClosingTable represents closings view or table in SQL database.

View Source
var ContractTable = &contractTableType{
	s: parse.StructInfo{Type: "Contract", SQLSchema: "", SQLName: "contracts", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "Address", Type: "HexString", Column: "address"}, {Name: "Type", Type: "string", Column: "type"}, {Name: "Version", Type: "*uint8", Column: "version"}, {Name: "Enabled", Type: "bool", Column: "enabled"}}, PKFieldIndex: 0},
	z: new(Contract).Values(),
}

ContractTable represents contracts view or table in SQL database.

View Source
var EndpointTable = &endpointTableType{
	s: parse.StructInfo{Type: "Endpoint", SQLSchema: "", SQLName: "endpoints", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "Template", Type: "string", Column: "template"}, {Name: "Channel", Type: "string", Column: "channel"}, {Name: "Hash", Type: "HexString", Column: "hash"}, {Name: "RawMsg", Type: "Base64String", Column: "raw_msg"}, {Name: "PaymentReceiverAddress", Type: "*string", Column: "payment_receiver_address"}, {Name: "ServiceEndpointAddress", Type: "*string", Column: "service_endpoint_address"}, {Name: "Username", Type: "*string", Column: "username"}, {Name: "Password", Type: "*string", Column: "password"}, {Name: "AdditionalParams", Type: "[]uint8", Column: "additional_params"}, {Name: "CountryStatus", Type: "*string", Column: "country_status"}}, PKFieldIndex: 0},
	z: new(Endpoint).Values(),
}

EndpointTable represents endpoints view or table in SQL database.

View Source
var EndpointUITable = &endpointUITableType{
	s: parse.StructInfo{Type: "EndpointUI", SQLSchema: "", SQLName: "endpoints", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "PaymentReceiverAddress", Type: "*string", Column: "payment_receiver_address"}, {Name: "ServiceEndpointAddress", Type: "*string", Column: "service_endpoint_address"}, {Name: "CountryStatus", Type: "*string", Column: "country_status"}}, PKFieldIndex: 0},
	z: new(EndpointUI).Values(),
}

EndpointUITable represents endpoints view or table in SQL database.

View Source
var EthTxTable = &ethTxTableType{
	s: parse.StructInfo{Type: "EthTx", SQLSchema: "", SQLName: "eth_txs", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "Hash", Type: "HexString", Column: "hash"}, {Name: "Method", Type: "string", Column: "method"}, {Name: "Status", Type: "string", Column: "status"}, {Name: "JobID", Type: "*string", Column: "job"}, {Name: "Issued", Type: "time.Time", Column: "issued"}, {Name: "AddrFrom", Type: "HexString", Column: "addr_from"}, {Name: "AddrTo", Type: "HexString", Column: "addr_to"}, {Name: "Nonce", Type: "*string", Column: "nonce"}, {Name: "GasPrice", Type: "uint64", Column: "gas_price"}, {Name: "Gas", Type: "uint64", Column: "gas"}, {Name: "TxRaw", Type: "[]uint8", Column: "tx_raw"}, {Name: "RelatedType", Type: "string", Column: "related_type"}, {Name: "RelatedID", Type: "string", Column: "related_id"}}, PKFieldIndex: 0},
	z: new(EthTx).Values(),
}

EthTxTable represents eth_txs view or table in SQL database.

View Source
var JobTable = &jobTableType{
	s: parse.StructInfo{Type: "Job", SQLSchema: "", SQLName: "jobs", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "Type", Type: "string", Column: "type"}, {Name: "Status", Type: "string", Column: "status"}, {Name: "RelatedType", Type: "string", Column: "related_type"}, {Name: "RelatedID", Type: "string", Column: "related_id"}, {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, {Name: "NotBefore", Type: "time.Time", Column: "not_before"}, {Name: "CreatedBy", Type: "string", Column: "created_by"}, {Name: "TryCount", Type: "uint8", Column: "try_count"}, {Name: "Data", Type: "[]uint8", Column: "data"}}, PKFieldIndex: 0},
	z: new(Job).Values(),
}

JobTable represents jobs view or table in SQL database.

View Source
var LogEventView = &logEventViewType{
	s: parse.StructInfo{Type: "LogEvent", SQLSchema: "", SQLName: "log_events", Fields: []parse.FieldInfo{{Name: "Time", Type: "time.Time", Column: "time"}, {Name: "Level", Type: "log.Level", Column: "level"}, {Name: "Message", Type: "string", Column: "message"}, {Name: "Context", Type: "json.RawMessage", Column: "context"}, {Name: "Stack", Type: "*string", Column: "stack"}}, PKFieldIndex: -1},
	z: new(LogEvent).Values(),
}

LogEventView represents log_events view or table in SQL database.

View Source
var OfferingTable = &offeringTableType{
	s: parse.StructInfo{Type: "Offering", SQLSchema: "", SQLName: "offerings", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "IsLocal", Type: "bool", Column: "is_local"}, {Name: "IPType", Type: "string", Column: "ip_type"}, {Name: "Template", Type: "string", Column: "tpl"}, {Name: "Product", Type: "string", Column: "product"}, {Name: "Hash", Type: "HexString", Column: "hash"}, {Name: "Status", Type: "string", Column: "status"}, {Name: "BlockNumberUpdated", Type: "uint64", Column: "block_number_updated"}, {Name: "Agent", Type: "HexString", Column: "agent"}, {Name: "RawMsg", Type: "Base64String", Column: "raw_msg"}, {Name: "ServiceName", Type: "string", Column: "service_name"}, {Name: "Description", Type: "*string", Column: "description"}, {Name: "Country", Type: "string", Column: "country"}, {Name: "Supply", Type: "uint16", Column: "supply"}, {Name: "CurrentSupply", Type: "uint16", Column: "current_supply"}, {Name: "UnitName", Type: "string", Column: "unit_name"}, {Name: "UnitType", Type: "string", Column: "unit_type"}, {Name: "BillingType", Type: "string", Column: "billing_type"}, {Name: "SetupPrice", Type: "uint64", Column: "setup_price"}, {Name: "UnitPrice", Type: "uint64", Column: "unit_price"}, {Name: "MinUnits", Type: "uint64", Column: "min_units"}, {Name: "MaxUnit", Type: "*uint64", Column: "max_unit"}, {Name: "BillingInterval", Type: "uint", Column: "billing_interval"}, {Name: "MaxBillingUnitLag", Type: "uint", Column: "max_billing_unit_lag"}, {Name: "MaxSuspendTime", Type: "uint", Column: "max_suspended_time"}, {Name: "MaxInactiveTimeSec", Type: "uint64", Column: "max_inactive_time_sec"}, {Name: "FreeUnits", Type: "uint8", Column: "free_units"}, {Name: "AdditionalParams", Type: "json.RawMessage", Column: "additional_params"}, {Name: "AutoPopUp", Type: "*bool", Column: "auto_pop_up"}, {Name: "SOMCType", Type: "uint8", Column: "somc_type"}, {Name: "SOMCData", Type: "Base64String", Column: "somc_data"}, {Name: "SOMCSuccessPing", Type: "*time.Time", Column: "somc_success_ping"}}, PKFieldIndex: 0},
	z: new(Offering).Values(),
}

OfferingTable represents offerings view or table in SQL database.

View Source
var ProductTable = &productTableType{
	s: parse.StructInfo{Type: "Product", SQLSchema: "", SQLName: "products", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "Name", Type: "string", Column: "name"}, {Name: "OfferTplID", Type: "*string", Column: "offer_tpl_id"}, {Name: "OfferAccessID", Type: "*string", Column: "offer_access_id"}, {Name: "UsageRepType", Type: "string", Column: "usage_rep_type"}, {Name: "IsServer", Type: "bool", Column: "is_server"}, {Name: "Salt", Type: "uint64", Column: "salt"}, {Name: "Password", Type: "Base64String", Column: "password"}, {Name: "ClientIdent", Type: "string", Column: "client_ident"}, {Name: "Config", Type: "json.RawMessage", Column: "config"}, {Name: "ServiceEndpointAddress", Type: "*string", Column: "service_endpoint_address"}, {Name: "Country", Type: "*string", Column: "country"}}, PKFieldIndex: 0},
	z: new(Product).Values(),
}

ProductTable represents products view or table in SQL database.

View Source
var RatingTable = &ratingTableType{
	s: parse.StructInfo{Type: "Rating", SQLSchema: "", SQLName: "ratings", Fields: []parse.FieldInfo{{Name: "EthAddr", Type: "HexString", Column: "eth_addr"}, {Name: "Val", Type: "uint64", Column: "val"}}, PKFieldIndex: 0},
	z: new(Rating).Values(),
}

RatingTable represents ratings view or table in SQL database.

View Source
var SessionTable = &sessionTableType{
	s: parse.StructInfo{Type: "Session", SQLSchema: "", SQLName: "sessions", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "Channel", Type: "string", Column: "channel"}, {Name: "Started", Type: "time.Time", Column: "started"}, {Name: "Stopped", Type: "*time.Time", Column: "stopped"}, {Name: "UnitsUsed", Type: "uint64", Column: "units_used"}, {Name: "SecondsConsumed", Type: "uint64", Column: "seconds_consumed"}, {Name: "LastUsageTime", Type: "time.Time", Column: "last_usage_time"}, {Name: "ClientIP", Type: "*string", Column: "client_ip"}, {Name: "ClientPort", Type: "*uint16", Column: "client_port"}}, PKFieldIndex: 0},
	z: new(Session).Values(),
}

SessionTable represents sessions view or table in SQL database.

View Source
var SettingTable = &settingTableType{
	s: parse.StructInfo{Type: "Setting", SQLSchema: "", SQLName: "settings", Fields: []parse.FieldInfo{{Name: "Key", Type: "string", Column: "key"}, {Name: "Value", Type: "string", Column: "value"}, {Name: "Permissions", Type: "int", Column: "permissions"}, {Name: "Description", Type: "*string", Column: "description"}, {Name: "Name", Type: "string", Column: "name"}}, PKFieldIndex: 0},
	z: new(Setting).Values(),
}

SettingTable represents settings view or table in SQL database.

View Source
var TemplateTable = &templateTableType{
	s: parse.StructInfo{Type: "Template", SQLSchema: "", SQLName: "templates", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "Hash", Type: "HexString", Column: "hash"}, {Name: "Raw", Type: "json.RawMessage", Column: "raw"}, {Name: "Kind", Type: "string", Column: "kind"}}, PKFieldIndex: 0},
	z: new(Template).Values(),
}

TemplateTable represents templates view or table in SQL database.

View Source
var UserTable = &userTableType{
	s: parse.StructInfo{Type: "User", SQLSchema: "", SQLName: "users", Fields: []parse.FieldInfo{{Name: "ID", Type: "string", Column: "id"}, {Name: "EthAddr", Type: "HexString", Column: "eth_addr"}, {Name: "PublicKey", Type: "Base64String", Column: "public_key"}}, PKFieldIndex: 0},
	z: new(User).Values(),
}

UserTable represents users view or table in SQL database.

Functions

func BeginTestTX

func BeginTestTX(t *testing.T, db *reform.DB) *reform.TX

BeginTestTX begins a test transaction.

func BytesToUint32

func BytesToUint32(b []byte) (uint32, error)

BytesToUint32 using big endian.

func ChannelKey

func ChannelKey(client, agent HexString, block uint32,
	offeringHash HexString) ([]byte, error)

ChannelKey returns the unique channel identifier used in a Privatix Service Contract.

func CleanTestDB

func CleanTestDB(t *testing.T, db *reform.DB)

CleanTestDB deletes all records from all test DB tables.

func CleanTestTable

func CleanTestTable(t *testing.T, db *reform.DB, tbl reform.View)

CleanTestTable deletes all records from a given DB table.

func CloseDB

func CloseDB(db *reform.DB)

CloseDB closes database connection.

func CommitTestTX

func CommitTestTX(t *testing.T, tx *reform.TX)

CommitTestTX commits a test transaction.

func ComputePrice added in v0.23.0

func ComputePrice(offering *Offering, units uint64) uint64

ComputePrice calculates price for units of offering.

func DeleteFromTestDB

func DeleteFromTestDB(t *testing.T, db *reform.DB, recs ...reform.Record)

DeleteFromTestDB deletes records from test DB.

func ExecuteCommand

func ExecuteCommand(args []string) error

ExecuteCommand executes commands to manage database db-create - command to create database db-migrate - command to execute migration scripts db-load-data - command to initialize database by default values db-version - command to print the version of the database schema.

func FindByPrimaryKeyTo

func FindByPrimaryKeyTo(db *reform.Querier,
	rec reform.Record, key interface{}) error

FindByPrimaryKeyTo calls db.FindByPrimaryKeyTo() returning more descriptive error.

func FindInTestDB

func FindInTestDB(t *testing.T, db *reform.DB,
	str reform.Struct, column string, arg interface{})

FindInTestDB selects a record from test DB.

func FindOneTo

func FindOneTo(db *reform.Querier,
	str reform.Struct, column string, arg interface{}) error

FindOneTo calls db.FindOneTo() returning more descriptive error.

func FromBase64ToHex

func FromBase64ToHex(s Base64String) (string, error)

FromBase64ToHex return hex of base 64 encoded.

func GetUint64Setting

func GetUint64Setting(db *reform.DB, key string) (uint64, error)

GetUint64Setting finds the key value in table Setting. Checks that the value in the format of uint64

func HexToAddress

func HexToAddress(addr HexString) (common.Address, error)

HexToAddress returns ethereum's address from base 64 encoded string.

func HexToBytes

func HexToBytes(s HexString) ([]byte, error)

HexToBytes reutrns the bytes represented by the hex of string s.

func HexToHash

func HexToHash(h HexString) (common.Hash, error)

HexToHash returns the ethereum's hash represented by the hex of string s.

func Insert

func Insert(db *reform.Querier, str reform.Struct) error

Insert calls db.Insert() returning more descriptive error.

func InsertToTestDB

func InsertToTestDB(t *testing.T, db *reform.DB, rows ...reform.Struct)

InsertToTestDB inserts rows to test DB.

func NewDB

func NewDB(conf *DBConfig) (*reform.DB, error)

NewDB creates a new data connection handle.

func NewDBFromConnStr

func NewDBFromConnStr(connStr string) (*reform.DB, error)

NewDBFromConnStr connects to db and returns db instance.

func NewTestDB

func NewTestDB(conf *DBConfig) *reform.DB

NewTestDB creates a new database connection.

func ReadBoolSetting

func ReadBoolSetting(db *reform.Querier, key string) (bool, error)

ReadBoolSetting reads value of a given bool setting.

func ReadSetting

func ReadSetting(db *reform.Querier, key string) (string, error)

ReadSetting reads value of a given setting.

func ReadUint64Setting added in v0.23.0

func ReadUint64Setting(db *reform.Querier, key string) (uint64, error)

ReadUint64Setting reads value of a given uint setting.

func ReadUintSetting

func ReadUintSetting(db *reform.Querier, key string) (uint, error)

ReadUintSetting reads value of a given uint setting.

func Recover

func Recover(db *reform.DB) error

Recover ensures data consistency after unexpected controller's exit.

func ReloadFromTestDB

func ReloadFromTestDB(t *testing.T, db *reform.DB, recs ...reform.Record)

ReloadFromTestDB reloads records from test DB.

func RollbackTestTX

func RollbackTestTX(t *testing.T, tx *reform.TX)

RollbackTestTX rollbacks a test transaction.

func Save

func Save(db *reform.Querier, rec reform.Record) error

Save calls db.Save() returning more descriptive error.

func SaveToTestDB

func SaveToTestDB(t *testing.T, db *reform.DB, recs ...reform.Record)

SaveToTestDB saves records to test DB.

func SelectOneFromTestDBTo

func SelectOneFromTestDBTo(t *testing.T, db *reform.DB,
	str reform.Struct, tail string, args ...interface{})

SelectOneFromTestDBTo selects a record from test DB using a given query tail.

func TestToAddress

func TestToAddress(t *testing.T, addr HexString) common.Address

TestToAddress decodes to address or fails.

func TestToBytes

func TestToBytes(t *testing.T, s Base64String) []byte

TestToBytes returns binary representation of base64 encoded string or fails.

func TestToHash

func TestToHash(t *testing.T, h HexString) common.Hash

TestToHash decodes to hash or fails.

func TestToPrivateKey

func TestToPrivateKey(
	keyB64 Base64String, _ string) (*ecdsa.PrivateKey, error)

TestToPrivateKey is a key decryption simplified for tests performance.

func ToBytes

func ToBytes(s Base64String) ([]byte, error)

ToBytes returns the bytes represented by the base64 string s.

func ToHash

func ToHash(h Base64String) (common.Hash, error)

ToHash returns the ethereum's hash represented by the base64 string s.

func ToPrivateKey

func ToPrivateKey(keyB64 Base64String, auth string) (*ecdsa.PrivateKey, error)

ToPrivateKey returns decrypted *ecdsa.PrivateKey from base64 of encrypted keystore.Key.

func Uint192ToBytes

func Uint192ToBytes(x *big.Int) [24]byte

Uint192ToBytes using big endian with leading zeros.

func Uint32ToBytes

func Uint32ToBytes(x uint32) [4]byte

Uint32ToBytes using big endian.

func Uint64ToBytes

func Uint64ToBytes(x uint64) [8]byte

Uint64ToBytes using big endian.

func UpdateUint64Setting added in v1.1.0

func UpdateUint64Setting(db *reform.Querier, key string, val uint64) error

UpdateUint64Setting reads value of a given uint setting.

func ValidatePassword

func ValidatePassword(hash Base64String, password, salt string) error

ValidatePassword checks if a given password, hash and salt are matching.

Types

type Account

type Account struct {
	ID               string       `json:"id" reform:"id,pk"`
	EthAddr          HexString    `json:"ethAddr" reform:"eth_addr"`
	PublicKey        Base64String `json:"-" reform:"public_key"`
	PrivateKey       Base64String `json:"-" reform:"private_key"`
	IsDefault        bool         `json:"isDefault" reform:"is_default"`
	InUse            bool         `json:"inUse" reform:"in_use"`
	Name             string       `json:"name" reform:"name"`
	PTCBalance       uint64       `json:"ptcBalance" reform:"ptc_balance"`
	PSCBalance       uint64       `json:"pscBalance" reform:"psc_balance"`
	EthBalance       Base64BigInt `json:"ethBalance" reform:"eth_balance"`
	LastBalanceCheck *time.Time   `json:"lastBalanceCheck" reform:"last_balance_check"`
}

Account is an ethereum account.

func NewEthTestAccount

func NewEthTestAccount(auth string, acc *truffle.TestAccount) *Account

NewEthTestAccount returns new account based on truffle.TestAccount.

func NewTestAccount

func NewTestAccount(auth string) *Account

NewTestAccount returns new account.

func (*Account) HasPK added in v0.22.0

func (s *Account) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Account) PKPointer added in v0.22.0

func (s *Account) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Account) PKValue added in v0.22.0

func (s *Account) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Account) Pointers added in v0.22.0

func (s *Account) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Account) SetPK added in v0.22.0

func (s *Account) SetPK(pk interface{})

SetPK sets record primary key.

func (Account) String added in v0.22.0

func (s Account) String() string

String returns a string representation of this struct or record.

func (*Account) Table added in v0.22.0

func (s *Account) Table() reform.Table

Table returns Table object for that record.

func (*Account) Values added in v0.22.0

func (s *Account) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Account) View added in v0.22.0

func (s *Account) View() reform.View

View returns View object for that struct.

type Base64BigInt

type Base64BigInt string

Base64BigInt is a base64 of big.Int that implements json.Marshaler.

func (Base64BigInt) MarshalJSON

func (n Base64BigInt) MarshalJSON() ([]byte, error)

MarshalJSON marshals itself.

type Base64String

type Base64String string

Base64String is a base64-encoded binary data.

func EncryptedKey

func EncryptedKey(pkey *ecdsa.PrivateKey, auth string) (Base64String, error)

EncryptedKey returns encrypted keystore.Key in base64.

func FromBytes

func FromBytes(src []byte) Base64String

FromBytes returns the base64 encoding of src.

func HashPassword

func HashPassword(password, salt string) (Base64String, error)

HashPassword computes encoded hash of the password.

func TestEncryptedKey

func TestEncryptedKey(pkey *ecdsa.PrivateKey, _ string) (Base64String, error)

TestEncryptedKey is a key encryption simplified for tests performance.

type Channel

type Channel struct {
	ID                 string        `json:"id" reform:"id,pk"`
	Agent              HexString     `json:"agent" reform:"agent"`
	Client             HexString     `json:"client" reform:"client"`
	Offering           string        `json:"offering" reform:"offering"`
	Block              uint32        `json:"block" reform:"block"`                  // When state channel created.
	ChannelStatus      string        `json:"channelStatus" reform:"channel_status"` // Status related to blockchain.
	ServiceStatus      string        `json:"serviceStatus" reform:"service_status"`
	ServiceChangedTime *time.Time    `json:"serviceChangedTime" reform:"service_changed_time"`
	PreparedAt         time.Time     `json:"preparedAt" reform:"prepared_at"`
	TotalDeposit       uint64        `json:"totalDeposit" reform:"total_deposit"`
	Salt               uint64        `json:"-" reform:"salt"`
	Username           *string       `json:"-" reform:"username"`
	Password           Base64String  `json:"-" reform:"password"`
	ReceiptBalance     uint64        `json:"receiptBalance" reform:"receipt_balance"` // Last payment.
	ReceiptSignature   *Base64String `json:"-" reform:"receipt_signature"`            // Last payment's signature.
}

Channel is a state channel.

func NewTestChannel

func NewTestChannel(agent, client HexString, offering string,
	balance, deposit uint64, status string) *Channel

NewTestChannel returns new channel.

func (*Channel) HasPK added in v0.22.0

func (s *Channel) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Channel) PKPointer added in v0.22.0

func (s *Channel) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Channel) PKValue added in v0.22.0

func (s *Channel) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Channel) Pointers added in v0.22.0

func (s *Channel) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Channel) SetPK added in v0.22.0

func (s *Channel) SetPK(pk interface{})

SetPK sets record primary key.

func (Channel) String added in v0.22.0

func (s Channel) String() string

String returns a string representation of this struct or record.

func (*Channel) Table added in v0.22.0

func (s *Channel) Table() reform.Table

Table returns Table object for that record.

func (*Channel) Values added in v0.22.0

func (s *Channel) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Channel) View added in v0.22.0

func (s *Channel) View() reform.View

View returns View object for that struct.

type Closing added in v1.0.0

type Closing struct {
	ID      string    `reform:"id,pk" json:"id"`
	Type    string    `reform:"type" json:"type"`
	Agent   HexString `reform:"agent" json:"agent"`
	Client  HexString `reform:"client" json:"client"`
	Balance uint64    `reform:"balance" json:"balance"`
	Block   uint32    `reform:"block" json:"block"`
}

Closing is a channels closings from blockchain. Records are used in rating calculation.

func (*Closing) HasPK added in v1.0.0

func (s *Closing) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Closing) PKPointer added in v1.0.0

func (s *Closing) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Closing) PKValue added in v1.0.0

func (s *Closing) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Closing) Pointers added in v1.0.0

func (s *Closing) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Closing) SetPK added in v1.0.0

func (s *Closing) SetPK(pk interface{})

SetPK sets record primary key.

func (Closing) String added in v1.0.0

func (s Closing) String() string

String returns a string representation of this struct or record.

func (*Closing) Table added in v1.0.0

func (s *Closing) Table() reform.Table

Table returns Table object for that record.

func (*Closing) Values added in v1.0.0

func (s *Closing) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Closing) View added in v1.0.0

func (s *Closing) View() reform.View

View returns View object for that struct.

type Contract

type Contract struct {
	ID      string    `json:"id" reform:"id,pk"`
	Address HexString `json:"address" reform:"address"` // Ethereum address
	Type    string    `json:"type" reform:"type"`
	Version *uint8    `json:"version" reform:"version"`
	Enabled bool      `json:"enabled" reform:"enabled"`
}

Contract is a smart contract.

func (*Contract) HasPK added in v0.22.0

func (s *Contract) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Contract) PKPointer added in v0.22.0

func (s *Contract) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Contract) PKValue added in v0.22.0

func (s *Contract) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Contract) Pointers added in v0.22.0

func (s *Contract) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Contract) SetPK added in v0.22.0

func (s *Contract) SetPK(pk interface{})

SetPK sets record primary key.

func (Contract) String added in v0.22.0

func (s Contract) String() string

String returns a string representation of this struct or record.

func (*Contract) Table added in v0.22.0

func (s *Contract) Table() reform.Table

Table returns Table object for that record.

func (*Contract) Values added in v0.22.0

func (s *Contract) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Contract) View added in v0.22.0

func (s *Contract) View() reform.View

View returns View object for that struct.

type DBConfig

type DBConfig struct {
	Conn     map[string]string
	MaxOpen  int
	MaxIddle int
}

DBConfig is a DB configuration.

func NewDBConfig

func NewDBConfig() *DBConfig

NewDBConfig creates a default DB configuration.

func (DBConfig) ConnStr

func (c DBConfig) ConnStr() string

ConnStr composes a data connection string.

type EncryptedKeyFunc

type EncryptedKeyFunc func(*ecdsa.PrivateKey, string) (Base64String, error)

EncryptedKeyFunc is a func that returns encrypted keystore.Key in base64.

type Endpoint

type Endpoint struct {
	ID                     string       `json:"id" reform:"id,pk"`
	Template               string       `json:"template" reform:"template"`
	Channel                string       `json:"channel" reform:"channel"`
	Hash                   HexString    `json:"hash" reform:"hash"`
	RawMsg                 Base64String `reform:"raw_msg"`
	PaymentReceiverAddress *string      `json:"paymentReceiverAddress" reform:"payment_receiver_address"`
	ServiceEndpointAddress *string      `json:"serviceEndpointAddress" reform:"service_endpoint_address"`
	Username               *string      `json:"username" reform:"username"`
	Password               *string      `json:"password" reform:"password"`
	AdditionalParams       []byte       `json:"additionalParams" reform:"additional_params"`
	CountryStatus          *string      `json:"countryStatus" reform:"country_status"`
}

Endpoint messages is info about service access.

func NewTestEndpoint

func NewTestEndpoint(chanID, tplID string) *Endpoint

NewTestEndpoint returns new endpoint.

func (*Endpoint) HasPK added in v0.22.0

func (s *Endpoint) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Endpoint) PKPointer added in v0.22.0

func (s *Endpoint) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Endpoint) PKValue added in v0.22.0

func (s *Endpoint) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Endpoint) Pointers added in v0.22.0

func (s *Endpoint) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Endpoint) SetPK added in v0.22.0

func (s *Endpoint) SetPK(pk interface{})

SetPK sets record primary key.

func (Endpoint) String added in v0.22.0

func (s Endpoint) String() string

String returns a string representation of this struct or record.

func (*Endpoint) Table added in v0.22.0

func (s *Endpoint) Table() reform.Table

Table returns Table object for that record.

func (*Endpoint) Values added in v0.22.0

func (s *Endpoint) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Endpoint) View added in v0.22.0

func (s *Endpoint) View() reform.View

View returns View object for that struct.

type EndpointUI

type EndpointUI struct {
	ID                     string  `json:"id" reform:"id,pk"`
	PaymentReceiverAddress *string `json:"paymentReceiverAddress" reform:"payment_receiver_address"`
	ServiceEndpointAddress *string `json:"serviceEndpointAddress" reform:"service_endpoint_address"`
	CountryStatus          *string `json:"countryStatus" reform:"country_status"`
}

EndpointUI contains only certain fields of endpoints table.

func (*EndpointUI) HasPK added in v0.22.0

func (s *EndpointUI) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*EndpointUI) PKPointer added in v0.22.0

func (s *EndpointUI) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*EndpointUI) PKValue added in v0.22.0

func (s *EndpointUI) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*EndpointUI) Pointers added in v0.22.0

func (s *EndpointUI) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*EndpointUI) SetPK added in v0.22.0

func (s *EndpointUI) SetPK(pk interface{})

SetPK sets record primary key.

func (EndpointUI) String added in v0.22.0

func (s EndpointUI) String() string

String returns a string representation of this struct or record.

func (*EndpointUI) Table added in v0.22.0

func (s *EndpointUI) Table() reform.Table

Table returns Table object for that record.

func (*EndpointUI) Values added in v0.22.0

func (s *EndpointUI) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*EndpointUI) View added in v0.22.0

func (s *EndpointUI) View() reform.View

View returns View object for that struct.

type EthTx

type EthTx struct {
	ID          string    `reform:"id,pk" json:"id"`
	Hash        HexString `reform:"hash" json:"hash"`
	Method      string    `reform:"method" json:"method"`
	Status      string    `reform:"status" json:"status"`
	JobID       *string   `reform:"job" json:"jobID"`
	Issued      time.Time `reform:"issued" json:"issued"`
	AddrFrom    HexString `reform:"addr_from" json:"addrFrom"`
	AddrTo      HexString `reform:"addr_to" json:"addrTo"`
	Nonce       *string   `reform:"nonce" json:"nonce"`
	GasPrice    uint64    `reform:"gas_price" json:"gasPrice"`
	Gas         uint64    `reform:"gas" json:"gas"`
	TxRaw       []byte    `reform:"tx_raw" json:"txRaw"`
	RelatedType string    `reform:"related_type" json:"relatedType"`
	RelatedID   string    `reform:"related_id" json:"relatedID"`
}

EthTx is an ethereum transaction

func (*EthTx) HasPK added in v0.22.0

func (s *EthTx) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*EthTx) PKPointer added in v0.22.0

func (s *EthTx) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*EthTx) PKValue added in v0.22.0

func (s *EthTx) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*EthTx) Pointers added in v0.22.0

func (s *EthTx) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*EthTx) SetPK added in v0.22.0

func (s *EthTx) SetPK(pk interface{})

SetPK sets record primary key.

func (EthTx) String added in v0.22.0

func (s EthTx) String() string

String returns a string representation of this struct or record.

func (*EthTx) Table added in v0.22.0

func (s *EthTx) Table() reform.Table

Table returns Table object for that record.

func (*EthTx) Values added in v0.22.0

func (s *EthTx) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*EthTx) View added in v0.22.0

func (s *EthTx) View() reform.View

View returns View object for that struct.

type HexString

type HexString string

HexString is a hex-encoded binary data.

func HexFromBytes

func HexFromBytes(src []byte) HexString

HexFromBytes returns the hex encoding of src.

type Job

type Job struct {
	ID          string    `reform:"id,pk"`
	Type        string    `reform:"type"`
	Status      string    `reform:"status"`
	RelatedType string    `reform:"related_type"`
	RelatedID   string    `reform:"related_id"`
	CreatedAt   time.Time `reform:"created_at"`
	NotBefore   time.Time `reform:"not_before"`
	CreatedBy   string    `reform:"created_by"`
	TryCount    uint8     `reform:"try_count"`
	Data        []byte    `reform:"data"`
}

Job is a task within persistent queue.

func NewTestJob

func NewTestJob(jobType, createdBy, relType string) *Job

NewTestJob returns a default test job.

func (*Job) HasPK added in v0.22.0

func (s *Job) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Job) PKPointer added in v0.22.0

func (s *Job) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Job) PKValue added in v0.22.0

func (s *Job) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Job) Pointers added in v0.22.0

func (s *Job) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Job) SetPK added in v0.22.0

func (s *Job) SetPK(pk interface{})

SetPK sets record primary key.

func (Job) String added in v0.22.0

func (s Job) String() string

String returns a string representation of this struct or record.

func (*Job) Table added in v0.22.0

func (s *Job) Table() reform.Table

Table returns Table object for that record.

func (*Job) Values added in v0.22.0

func (s *Job) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Job) View added in v0.22.0

func (s *Job) View() reform.View

View returns View object for that struct.

type JobBalanceData

type JobBalanceData struct {
	GasPrice uint64
	Amount   uint64
}

JobBalanceData is a data required for transfer jobs.

type JobCreateChannelData

type JobCreateChannelData struct {
	GasPrice uint64
	Deposit  uint
}

JobCreateChannelData is a data required by client to accept an offering.

type JobData

type JobData struct {
	EthLog *JobEthLog `json:"ethereumLog"`
}

JobData data set by blockchain monitor for log derived jobs.

type JobEndpointCreateData

type JobEndpointCreateData struct {
	EndpointSealed []byte
}

JobEndpointCreateData is a data for client endpoint create job.

type JobEthLog

type JobEthLog struct {
	Block  uint64    `json:"block"`
	Data   []byte    `json:"data"`
	Topics LogTopics `json:"topics"`
	TxHash HexString `json:"transactionHash"`
}

JobEthLog is log data a job derived from.

type JobPublishData

type JobPublishData struct {
	GasPrice uint64
}

JobPublishData is a data required for blockchain publish jobs.

type JobRecordClosingData added in v1.0.0

type JobRecordClosingData struct {
	Rec *Closing
	// UpdateRating is whether to update rating or not.
	UpdateRatings bool
}

JobRecordClosingData is a data for client record closing job.

type JobTopUpChannelData

type JobTopUpChannelData struct {
	GasPrice uint64
	Deposit  uint64
}

JobTopUpChannelData is a data for top up channel job.

type LogEvent

type LogEvent struct {
	Time    time.Time       `json:"time" reform:"time"`
	Level   log.Level       `json:"level" reform:"level"`
	Message string          `json:"message" reform:"message"`
	Context json.RawMessage `json:"context" reform:"context"`
	Stack   *string         `json:"stack" reform:"stack"`
}

LogEvent is a log event.

func (*LogEvent) Pointers added in v0.22.0

func (s *LogEvent) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (LogEvent) String added in v0.22.0

func (s LogEvent) String() string

String returns a string representation of this struct or record.

func (*LogEvent) Values added in v0.22.0

func (s *LogEvent) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*LogEvent) View added in v0.22.0

func (s *LogEvent) View() reform.View

View returns View object for that struct.

type LogTopics

type LogTopics []common.Hash

LogTopics is a database/sql compatible type for ethereum log topics.

func (*LogTopics) Scan

func (t *LogTopics) Scan(src interface{}) error

Scan deserializes the log topics.

func (LogTopics) Value

func (t LogTopics) Value() (driver.Value, error)

Value serializes the log topics.

type Offering

type Offering struct {
	ID                 string          `json:"id" reform:"id,pk"`
	IsLocal            bool            `json:"isLocal" reform:"is_local"`
	IPType             string          `json:"ipType" reform:"ip_type"`
	Template           string          `json:"template" reform:"tpl" validate:"required"`    // Offering's.
	Product            string          `json:"product" reform:"product" validate:"required"` // Specific billing and actions.
	Hash               HexString       `json:"hash" reform:"hash"`                           // Offering's hash.
	Status             string          `json:"status" reform:"status"`
	BlockNumberUpdated uint64          `json:"blockNumberUpdated" reform:"block_number_updated"`
	Agent              HexString       `json:"agent" reform:"agent" validate:"required"`
	RawMsg             Base64String    `json:"rawMsg" reform:"raw_msg"`
	ServiceName        string          `json:"serviceName" reform:"service_name" validate:"required"`
	Description        *string         `json:"description" reform:"description"`
	Country            string          `json:"country" reform:"country" validate:"required"` // ISO 3166-1 alpha-2.
	Supply             uint16          `json:"supply" reform:"supply" validate:"required"`
	CurrentSupply      uint16          `json:"currentSupply" reform:"current_supply"`
	UnitName           string          `json:"unitName" reform:"unit_name" validate:"required"` // Like megabytes, minutes, etc.
	UnitType           string          `json:"unitType" reform:"unit_type" validate:"required"`
	BillingType        string          `json:"billingType" reform:"billing_type" validate:"required"`
	SetupPrice         uint64          `json:"setupPrice" reform:"setup_price"` // Setup fee.
	UnitPrice          uint64          `json:"unitPrice" reform:"unit_price"`
	MinUnits           uint64          `json:"minUnits" reform:"min_units" validate:"required"`
	MaxUnit            *uint64         `json:"maxUnit" reform:"max_unit"`
	BillingInterval    uint            `json:"billingInterval" reform:"billing_interval" validate:"required"` // Every unit number to be paid.
	MaxBillingUnitLag  uint            `json:"maxBillingUnitLag" reform:"max_billing_unit_lag"`               // Max maximum tolerance for payment lag.
	MaxSuspendTime     uint            `json:"maxSuspendTime" reform:"max_suspended_time"`                    // In seconds.
	MaxInactiveTimeSec uint64          `json:"maxInactiveTimeSec" reform:"max_inactive_time_sec"`
	FreeUnits          uint8           `json:"freeUnits" reform:"free_units"`
	AdditionalParams   json.RawMessage `json:"additionalParams" reform:"additional_params" validate:"required"`
	AutoPopUp          *bool           `json:"autoPopUp" reform:"auto_pop_up"`
	SOMCType           uint8           `json:"somcType" reform:"somc_type"`
	SOMCData           Base64String    `json:"somcData" reform:"somc_data"`
	SOMCSuccessPing    *time.Time      `json:"somcSuccessPing" reform:"somc_success_ping"`
}

Offering is a service offering.

func NewTestOffering

func NewTestOffering(agent HexString, product, tpl string) *Offering

NewTestOffering returns new offering.

func (*Offering) HasPK added in v0.22.0

func (s *Offering) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Offering) PKPointer added in v0.22.0

func (s *Offering) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Offering) PKValue added in v0.22.0

func (s *Offering) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Offering) Pointers added in v0.22.0

func (s *Offering) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Offering) SetPK added in v0.22.0

func (s *Offering) SetPK(pk interface{})

SetPK sets record primary key.

func (Offering) String added in v0.22.0

func (s Offering) String() string

String returns a string representation of this struct or record.

func (*Offering) Table added in v0.22.0

func (s *Offering) Table() reform.Table

Table returns Table object for that record.

func (*Offering) Values added in v0.22.0

func (s *Offering) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Offering) View added in v0.22.0

func (s *Offering) View() reform.View

View returns View object for that struct.

type PWDGetSetter

type PWDGetSetter interface {
	PWDGetter
	PWDSetter
}

PWDGetSetter can get and set password to storage.

type PWDGetter

type PWDGetter interface {
	Get() string
	GetKey(*Account) (*ecdsa.PrivateKey, error)
}

PWDGetter can retrieve stored password.

type PWDSetter

type PWDSetter interface {
	Set(string)
}

PWDSetter can set new password.

type PWDStorage

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

PWDStorage stores password in memory.

func NewPWDStorage added in v1.0.1

func NewPWDStorage(decryptFunc ToPrivateKeyFunc) *PWDStorage

NewPWDStorage returns fresh instance of PWDStorage.

func (*PWDStorage) Get

func (s *PWDStorage) Get() string

Get returns stored password.

func (*PWDStorage) GetKey added in v1.0.1

func (s *PWDStorage) GetKey(acc *Account) (*ecdsa.PrivateKey, error)

GetKey returns private key of account.

func (*PWDStorage) Set

func (s *PWDStorage) Set(pwd string)

Set sets stored password.

type Product

type Product struct {
	ID                     string          `json:"id" reform:"id,pk"`
	Name                   string          `json:"name" reform:"name"`
	OfferTplID             *string         `json:"offerTplID" reform:"offer_tpl_id"`
	OfferAccessID          *string         `json:"offerAccessID" reform:"offer_access_id"`
	UsageRepType           string          `json:"usageRepType" reform:"usage_rep_type"`
	IsServer               bool            `json:"isServer" reform:"is_server"`
	Salt                   uint64          `json:"-" reform:"salt"`
	Password               Base64String    `json:"-" reform:"password"`
	ClientIdent            string          `json:"clientIdent" reform:"client_ident"`
	Config                 json.RawMessage `json:"config" reform:"config"`
	ServiceEndpointAddress *string         `json:"serviceEndpointAddress" reform:"service_endpoint_address"`
	Country                *string         `json:"country" reform:"country"`
}

Product stores billing and action related settings.

func NewTestProduct

func NewTestProduct() *Product

NewTestProduct returns new product.

func (*Product) HasPK added in v0.22.0

func (s *Product) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Product) PKPointer added in v0.22.0

func (s *Product) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Product) PKValue added in v0.22.0

func (s *Product) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Product) Pointers added in v0.22.0

func (s *Product) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Product) SetPK added in v0.22.0

func (s *Product) SetPK(pk interface{})

SetPK sets record primary key.

func (Product) String added in v0.22.0

func (s Product) String() string

String returns a string representation of this struct or record.

func (*Product) Table added in v0.22.0

func (s *Product) Table() reform.Table

Table returns Table object for that record.

func (*Product) Values added in v0.22.0

func (s *Product) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Product) View added in v0.22.0

func (s *Product) View() reform.View

View returns View object for that struct.

type Rating added in v1.0.0

type Rating struct {
	EthAddr HexString `reform:"eth_addr,pk" json:"eth_addr"`
	Val     uint64    `reform:"val" json:"val"`
}

Rating is a rating of an account.

func (*Rating) HasPK added in v1.0.0

func (s *Rating) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Rating) PKPointer added in v1.0.0

func (s *Rating) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Rating) PKValue added in v1.0.0

func (s *Rating) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Rating) Pointers added in v1.0.0

func (s *Rating) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Rating) SetPK added in v1.0.0

func (s *Rating) SetPK(pk interface{})

SetPK sets record primary key.

func (Rating) String added in v1.0.0

func (s Rating) String() string

String returns a string representation of this struct or record.

func (*Rating) Table added in v1.0.0

func (s *Rating) Table() reform.Table

Table returns Table object for that record.

func (*Rating) Values added in v1.0.0

func (s *Rating) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Rating) View added in v1.0.0

func (s *Rating) View() reform.View

View returns View object for that struct.

type Session

type Session struct {
	ID              string     `json:"id" reform:"id,pk"`
	Channel         string     `json:"channel" reform:"channel"`
	Started         time.Time  `json:"started" reform:"started"`
	Stopped         *time.Time `json:"stopped" reform:"stopped"`
	UnitsUsed       uint64     `json:"unitsUsed" reform:"units_used"`
	SecondsConsumed uint64     `json:"secondsConsumed" reform:"seconds_consumed"`
	LastUsageTime   time.Time  `json:"lastUsageTime" reform:"last_usage_time"`
	ClientIP        *string    `json:"clientIP" reform:"client_ip"`
	ClientPort      *uint16    `json:"clientPort" reform:"client_port"`
}

Session is a client session.

func NewTestSession

func NewTestSession(chanID string) *Session

NewTestSession returns new session.

func (*Session) HasPK added in v0.22.0

func (s *Session) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Session) PKPointer added in v0.22.0

func (s *Session) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Session) PKValue added in v0.22.0

func (s *Session) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Session) Pointers added in v0.22.0

func (s *Session) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Session) SetPK added in v0.22.0

func (s *Session) SetPK(pk interface{})

SetPK sets record primary key.

func (Session) String added in v0.22.0

func (s Session) String() string

String returns a string representation of this struct or record.

func (*Session) Table added in v0.22.0

func (s *Session) Table() reform.Table

Table returns Table object for that record.

func (*Session) Values added in v0.22.0

func (s *Session) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Session) View added in v0.22.0

func (s *Session) View() reform.View

View returns View object for that struct.

type Setting

type Setting struct {
	Key         string  `json:"key" reform:"key,pk"`
	Value       string  `json:"value" reform:"value"`
	Permissions int     `json:"permissions" reform:"permissions"`
	Description *string `json:"description" reform:"description"`
	Name        string  `json:"name" reform:"name"`
}

Setting is a user setting.

func (*Setting) HasPK added in v0.22.0

func (s *Setting) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Setting) PKPointer added in v0.22.0

func (s *Setting) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Setting) PKValue added in v0.22.0

func (s *Setting) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Setting) Pointers added in v0.22.0

func (s *Setting) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Setting) SetPK added in v0.22.0

func (s *Setting) SetPK(pk interface{})

SetPK sets record primary key.

func (Setting) String added in v0.22.0

func (s Setting) String() string

String returns a string representation of this struct or record.

func (*Setting) Table added in v0.22.0

func (s *Setting) Table() reform.Table

Table returns Table object for that record.

func (*Setting) Values added in v0.22.0

func (s *Setting) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Setting) View added in v0.22.0

func (s *Setting) View() reform.View

View returns View object for that struct.

type StaticPWDStorage

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

StaticPWDStorage returns static static password, can't be rewritten.

func NewStatisPWDStorage added in v1.0.1

func NewStatisPWDStorage(p string, decryptFunc ToPrivateKeyFunc) *StaticPWDStorage

NewStatisPWDStorage returns fresh instance of StaticPWDStorage.

func (*StaticPWDStorage) Get

func (s *StaticPWDStorage) Get() string

Get returns stored static password.

func (*StaticPWDStorage) GetKey added in v1.0.1

func (s *StaticPWDStorage) GetKey(acc *Account) (*ecdsa.PrivateKey, error)

GetKey returns private key of account.

func (*StaticPWDStorage) Set

func (s *StaticPWDStorage) Set(_ string)

Set does nothing.

type Template

type Template struct {
	ID   string          `json:"id" reform:"id,pk"`
	Hash HexString       `json:"hash" reform:"hash"`
	Raw  json.RawMessage `json:"raw" reform:"raw"`
	Kind string          `json:"kind" reform:"kind"`
}

Template is a user defined structures. It can be an offer or access template.

func NewTestTemplate

func NewTestTemplate(kind string) *Template

NewTestTemplate returns new tempalte.

func (*Template) HasPK added in v0.22.0

func (s *Template) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*Template) PKPointer added in v0.22.0

func (s *Template) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*Template) PKValue added in v0.22.0

func (s *Template) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*Template) Pointers added in v0.22.0

func (s *Template) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*Template) SetPK added in v0.22.0

func (s *Template) SetPK(pk interface{})

SetPK sets record primary key.

func (Template) String added in v0.22.0

func (s Template) String() string

String returns a string representation of this struct or record.

func (*Template) Table added in v0.22.0

func (s *Template) Table() reform.Table

Table returns Table object for that record.

func (*Template) Values added in v0.22.0

func (s *Template) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*Template) View added in v0.22.0

func (s *Template) View() reform.View

View returns View object for that struct.

type TestData

type TestData struct {
	Channel  string
	Password string
}

TestData is a container for testing data items.

type TestFixture

type TestFixture struct {
	T              *testing.T
	DB             *reform.DB
	Product        *Product
	Account        *Account
	UserAcc        *Account
	User           *User
	TemplateOffer  *Template
	TemplateAccess *Template
	Offering       *Offering
	Channel        *Channel
	Endpoint       *Endpoint
	EthTx          *EthTx
}

TestFixture encapsulates a typical set of DB objects useful for testing.

func NewTestFixture

func NewTestFixture(t *testing.T, db *reform.DB) *TestFixture

NewTestFixture creates a new test fixture.

func (*TestFixture) Close

func (f *TestFixture) Close()

Close closes a given test fixture.

type ToPrivateKeyFunc

type ToPrivateKeyFunc func(Base64String, string) (*ecdsa.PrivateKey, error)

ToPrivateKeyFunc is a func that returns decrypted *ecdsa.PrivateKey from base64 of encrypted keystore.Key.

type User

type User struct {
	ID        string       `json:"id" reform:"id,pk"`
	EthAddr   HexString    `json:"ethAddr" reform:"eth_addr"`
	PublicKey Base64String `json:"publicKey" reform:"public_key"`
}

User is party in distributed trade. It can play an agent role, a client role, or both of them.

func NewTestUser

func NewTestUser() *User

NewTestUser returns new subject.

func (*User) HasPK added in v0.22.0

func (s *User) HasPK() bool

HasPK returns true if record has non-zero primary key set, false otherwise.

func (*User) PKPointer added in v0.22.0

func (s *User) PKPointer() interface{}

PKPointer returns a pointer to primary key field for that record. Returned interface{} value is never untyped nil.

func (*User) PKValue added in v0.22.0

func (s *User) PKValue() interface{}

PKValue returns a value of primary key for that record. Returned interface{} value is never untyped nil.

func (*User) Pointers added in v0.22.0

func (s *User) Pointers() []interface{}

Pointers returns a slice of pointers to struct or record fields. Returned interface{} values are never untyped nils.

func (*User) SetPK added in v0.22.0

func (s *User) SetPK(pk interface{})

SetPK sets record primary key.

func (User) String added in v0.22.0

func (s User) String() string

String returns a string representation of this struct or record.

func (*User) Table added in v0.22.0

func (s *User) Table() reform.Table

Table returns Table object for that record.

func (*User) Values added in v0.22.0

func (s *User) Values() []interface{}

Values returns a slice of struct or record field values. Returned interface{} values are never untyped nils.

func (*User) View added in v0.22.0

func (s *User) View() reform.View

View returns View object for that struct.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL