Documentation ¶
Index ¶
- Constants
- Variables
- func BeginTestTX(t *testing.T, db *reform.DB) *reform.TX
- func BytesToUint32(b []byte) (uint32, error)
- func ChannelKey(client, agent HexString, block uint32, offeringHash HexString) ([]byte, error)
- func CleanTestDB(t *testing.T, db *reform.DB)
- func CleanTestTable(t *testing.T, db *reform.DB, tbl reform.View)
- func CloseDB(db *reform.DB)
- func CommitTestTX(t *testing.T, tx *reform.TX)
- func ComputePrice(offering *Offering, units uint64) uint64
- func DeleteFromTestDB(t *testing.T, db *reform.DB, recs ...reform.Record)
- func ExecuteCommand(args []string) error
- func FindByPrimaryKeyTo(db *reform.Querier, rec reform.Record, key interface{}) error
- func FindInTestDB(t *testing.T, db *reform.DB, str reform.Struct, column string, arg interface{})
- func FindOneTo(db *reform.Querier, str reform.Struct, column string, arg interface{}) error
- func FromBase64ToHex(s Base64String) (string, error)
- func GetUint64Setting(db *reform.DB, key string) (uint64, error)
- func HexToAddress(addr HexString) (common.Address, error)
- func HexToBytes(s HexString) ([]byte, error)
- func HexToHash(h HexString) (common.Hash, error)
- func Insert(db *reform.Querier, str reform.Struct) error
- func InsertToTestDB(t *testing.T, db *reform.DB, rows ...reform.Struct)
- func NewDB(conf *DBConfig) (*reform.DB, error)
- func NewDBFromConnStr(connStr string) (*reform.DB, error)
- func NewTestDB(conf *DBConfig) *reform.DB
- func ReadBoolSetting(db *reform.Querier, key string) (bool, error)
- func ReadSetting(db *reform.Querier, key string) (string, error)
- func ReadUint64Setting(db *reform.Querier, key string) (uint64, error)
- func ReadUintSetting(db *reform.Querier, key string) (uint, error)
- func Recover(db *reform.DB) error
- func ReloadFromTestDB(t *testing.T, db *reform.DB, recs ...reform.Record)
- func RollbackTestTX(t *testing.T, tx *reform.TX)
- func Save(db *reform.Querier, rec reform.Record) error
- func SaveToTestDB(t *testing.T, db *reform.DB, recs ...reform.Record)
- func SelectOneFromTestDBTo(t *testing.T, db *reform.DB, str reform.Struct, tail string, ...)
- func TestToAddress(t *testing.T, addr HexString) common.Address
- func TestToBytes(t *testing.T, s Base64String) []byte
- func TestToHash(t *testing.T, h HexString) common.Hash
- func TestToPrivateKey(keyB64 Base64String, _ string) (*ecdsa.PrivateKey, error)
- func ToBytes(s Base64String) ([]byte, error)
- func ToHash(h Base64String) (common.Hash, error)
- func ToPrivateKey(keyB64 Base64String, auth string) (*ecdsa.PrivateKey, error)
- func Uint192ToBytes(x *big.Int) [24]byte
- func Uint32ToBytes(x uint32) [4]byte
- func Uint64ToBytes(x uint64) [8]byte
- func UpdateUint64Setting(db *reform.Querier, key string, val uint64) error
- func ValidatePassword(hash Base64String, password, salt string) error
- type Account
- func (s *Account) HasPK() bool
- func (s *Account) PKPointer() interface{}
- func (s *Account) PKValue() interface{}
- func (s *Account) Pointers() []interface{}
- func (s *Account) SetPK(pk interface{})
- func (s Account) String() string
- func (s *Account) Table() reform.Table
- func (s *Account) Values() []interface{}
- func (s *Account) View() reform.View
- type Base64BigInt
- type Base64String
- type Channel
- func (s *Channel) HasPK() bool
- func (s *Channel) PKPointer() interface{}
- func (s *Channel) PKValue() interface{}
- func (s *Channel) Pointers() []interface{}
- func (s *Channel) SetPK(pk interface{})
- func (s Channel) String() string
- func (s *Channel) Table() reform.Table
- func (s *Channel) Values() []interface{}
- func (s *Channel) View() reform.View
- type Closing
- func (s *Closing) HasPK() bool
- func (s *Closing) PKPointer() interface{}
- func (s *Closing) PKValue() interface{}
- func (s *Closing) Pointers() []interface{}
- func (s *Closing) SetPK(pk interface{})
- func (s Closing) String() string
- func (s *Closing) Table() reform.Table
- func (s *Closing) Values() []interface{}
- func (s *Closing) View() reform.View
- type Contract
- func (s *Contract) HasPK() bool
- func (s *Contract) PKPointer() interface{}
- func (s *Contract) PKValue() interface{}
- func (s *Contract) Pointers() []interface{}
- func (s *Contract) SetPK(pk interface{})
- func (s Contract) String() string
- func (s *Contract) Table() reform.Table
- func (s *Contract) Values() []interface{}
- func (s *Contract) View() reform.View
- type DBConfig
- type EncryptedKeyFunc
- type Endpoint
- func (s *Endpoint) HasPK() bool
- func (s *Endpoint) PKPointer() interface{}
- func (s *Endpoint) PKValue() interface{}
- func (s *Endpoint) Pointers() []interface{}
- func (s *Endpoint) SetPK(pk interface{})
- func (s Endpoint) String() string
- func (s *Endpoint) Table() reform.Table
- func (s *Endpoint) Values() []interface{}
- func (s *Endpoint) View() reform.View
- type EndpointUI
- func (s *EndpointUI) HasPK() bool
- func (s *EndpointUI) PKPointer() interface{}
- func (s *EndpointUI) PKValue() interface{}
- func (s *EndpointUI) Pointers() []interface{}
- func (s *EndpointUI) SetPK(pk interface{})
- func (s EndpointUI) String() string
- func (s *EndpointUI) Table() reform.Table
- func (s *EndpointUI) Values() []interface{}
- func (s *EndpointUI) View() reform.View
- type EthTx
- func (s *EthTx) HasPK() bool
- func (s *EthTx) PKPointer() interface{}
- func (s *EthTx) PKValue() interface{}
- func (s *EthTx) Pointers() []interface{}
- func (s *EthTx) SetPK(pk interface{})
- func (s EthTx) String() string
- func (s *EthTx) Table() reform.Table
- func (s *EthTx) Values() []interface{}
- func (s *EthTx) View() reform.View
- type HexString
- type Job
- func (s *Job) HasPK() bool
- func (s *Job) PKPointer() interface{}
- func (s *Job) PKValue() interface{}
- func (s *Job) Pointers() []interface{}
- func (s *Job) SetPK(pk interface{})
- func (s Job) String() string
- func (s *Job) Table() reform.Table
- func (s *Job) Values() []interface{}
- func (s *Job) View() reform.View
- type JobBalanceData
- type JobCreateChannelData
- type JobData
- type JobEndpointCreateData
- type JobEthLog
- type JobPublishData
- type JobRecordClosingData
- type JobTopUpChannelData
- type LogEvent
- type LogTopics
- type Offering
- func (s *Offering) HasPK() bool
- func (s *Offering) PKPointer() interface{}
- func (s *Offering) PKValue() interface{}
- func (s *Offering) Pointers() []interface{}
- func (s *Offering) SetPK(pk interface{})
- func (s Offering) String() string
- func (s *Offering) Table() reform.Table
- func (s *Offering) Values() []interface{}
- func (s *Offering) View() reform.View
- type PWDGetSetter
- type PWDGetter
- type PWDSetter
- type PWDStorage
- type Product
- func (s *Product) HasPK() bool
- func (s *Product) PKPointer() interface{}
- func (s *Product) PKValue() interface{}
- func (s *Product) Pointers() []interface{}
- func (s *Product) SetPK(pk interface{})
- func (s Product) String() string
- func (s *Product) Table() reform.Table
- func (s *Product) Values() []interface{}
- func (s *Product) View() reform.View
- type Rating
- func (s *Rating) HasPK() bool
- func (s *Rating) PKPointer() interface{}
- func (s *Rating) PKValue() interface{}
- func (s *Rating) Pointers() []interface{}
- func (s *Rating) SetPK(pk interface{})
- func (s Rating) String() string
- func (s *Rating) Table() reform.Table
- func (s *Rating) Values() []interface{}
- func (s *Rating) View() reform.View
- type Session
- func (s *Session) HasPK() bool
- func (s *Session) PKPointer() interface{}
- func (s *Session) PKValue() interface{}
- func (s *Session) Pointers() []interface{}
- func (s *Session) SetPK(pk interface{})
- func (s Session) String() string
- func (s *Session) Table() reform.Table
- func (s *Session) Values() []interface{}
- func (s *Session) View() reform.View
- type Setting
- func (s *Setting) HasPK() bool
- func (s *Setting) PKPointer() interface{}
- func (s *Setting) PKValue() interface{}
- func (s *Setting) Pointers() []interface{}
- func (s *Setting) SetPK(pk interface{})
- func (s Setting) String() string
- func (s *Setting) Table() reform.Table
- func (s *Setting) Values() []interface{}
- func (s *Setting) View() reform.View
- type StaticPWDStorage
- type Template
- func (s *Template) HasPK() bool
- func (s *Template) PKPointer() interface{}
- func (s *Template) PKValue() interface{}
- func (s *Template) Pointers() []interface{}
- func (s *Template) SetPK(pk interface{})
- func (s Template) String() string
- func (s *Template) Table() reform.Table
- func (s *Template) Values() []interface{}
- func (s *Template) View() reform.View
- type TestData
- type TestFixture
- type ToPrivateKeyFunc
- type User
- func (s *User) HasPK() bool
- func (s *User) PKPointer() interface{}
- func (s *User) PKValue() interface{}
- func (s *User) Pointers() []interface{}
- func (s *User) SetPK(pk interface{})
- func (s User) String() string
- func (s *User) Table() reform.Table
- func (s *User) Values() []interface{}
- func (s *User) View() reform.View
Constants ¶
const ( JobUser = "user" JobBillingChecker = "billing_checker" JobBCMonitor = "bc_monitor" JobTask = "task" JobServiceAdapter = "service_adapter" JobSessionServer = "session_server" )
Job creators.
const ( JobActive = "active" JobDone = "done" JobFailed = "failed" JobCanceled = "canceled" )
Job statuses.
const ( JobOffering = "offering" JobChannel = "channel" JobEndpoint = "endpoint" JobAccount = "account" JobTransaction = "transaction" )
Job related object types.
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.
const ( RoleAgent = "agent" RoleClient = "client" )
Possible user roles.
const ( TemplateOffer = "offer" TemplateAccess = "access" )
Templates kinds.
const ( ProductUsageIncremental = "incremental" ProductUsageTotal = "total" )
Product usage reporting types.
const ( UnitScalar = "units" UnitSeconds = "seconds" )
Unit used for billing calculation.
const ( BillingPrepaid = "prepaid" BillingPostpaid = "postpaid" )
Billing types.
const ( OfferEmpty = "empty" OfferPoppingUp = "popping_up" OfferPoppedUp = "popped_up" OfferRegistering = "registering" OfferRegistered = "registered" OfferRemoving = "removing" OfferRemoved = "removed" )
Offering statuses.
const ( OfferingResidential = "residential" OfferingDatacenter = "datacenter" OfferingMobile = "mobile" )
Offering ip types.
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.
const ( ServicePending = "pending" ServiceActivating = "activating" ServiceActive = "active" ServiceSuspending = "suspending" ServiceSuspended = "suspended" ServiceTerminating = "terminating" ServiceTerminated = "terminated" )
Service operational statuses.
const ( ContractPTC = "ptc" ContractPSC = "psc" )
Contract types.
const ( AccessDenied = iota ReadOnly ReadWrite )
Permissions for settings.
const ( CountryStatusUnknown = "unknown" CountryStatusValid = "valid" CountryStatusInvalid = "invalid" )
Country statuses.
const ( TxUnsent = "unsent" TxSent = "sent" TxMined = "mined" TxUncle = "uncle" )
Transaction statuses.
const ( ClosingCoop = "coop" ClosingUncoop = "uncoop" )
Closing types. (Closings are used in rating calculation).
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.
const ( TestPassword = "secret" TestPasswordHash = "JDJhJDEwJHNVbWNtTkVwQk5DMkwuOC5OL1BXU08uYkJMMkxjcmthTW1BZklOTUNjNWZDdWNUOU54Tzlp" TestSalt = 6012867121110302348 )
Test authentication constants.
const (
ClientIdentByChannelID = "by_channel_id"
)
Product authentication types.
const (
OfferingSOMCTor uint8 = 1 + iota
)
Comminication types.
const (
TestServiceEndpointAddress = "localhost"
)
Test service addresses.
Variables ¶
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.
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.
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.
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.
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.
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.
var EthTxTable = ðTxTableType{ 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.
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.
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.
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.
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.
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.
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.
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.
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.
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 ¶
BeginTestTX begins a test transaction.
func ChannelKey ¶
ChannelKey returns the unique channel identifier used in a Privatix Service Contract.
func CleanTestDB ¶
CleanTestDB deletes all records from all test DB tables.
func CleanTestTable ¶
CleanTestTable deletes all records from a given DB table.
func CommitTestTX ¶
CommitTestTX commits a test transaction.
func ComputePrice ¶ added in v0.23.0
ComputePrice calculates price for units of offering.
func DeleteFromTestDB ¶
DeleteFromTestDB deletes records from test DB.
func ExecuteCommand ¶
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 ¶
FindInTestDB selects a record from test DB.
func FromBase64ToHex ¶
func FromBase64ToHex(s Base64String) (string, error)
FromBase64ToHex return hex of base 64 encoded.
func GetUint64Setting ¶
GetUint64Setting finds the key value in table Setting. Checks that the value in the format of uint64
func HexToAddress ¶
HexToAddress returns ethereum's address from base 64 encoded string.
func HexToBytes ¶
HexToBytes reutrns the bytes 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 ¶
InsertToTestDB inserts rows to test DB.
func NewDBFromConnStr ¶
NewDBFromConnStr connects to db and returns db instance.
func NewTestDB ¶
func NewTestDB(conf *DBConfig) *reform.DB
NewTestDB creates a new database connection.
func ReadBoolSetting ¶
ReadBoolSetting reads value of a given bool setting.
func ReadSetting ¶
ReadSetting reads value of a given setting.
func ReadUint64Setting ¶ added in v0.23.0
ReadUint64Setting reads value of a given uint setting.
func ReadUintSetting ¶
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 ¶
ReloadFromTestDB reloads records from test DB.
func RollbackTestTX ¶
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 ¶
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 ¶
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 ¶
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 ¶
Uint192ToBytes using big endian with leading zeros.
func UpdateUint64Setting ¶ added in v1.1.0
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 (*Account) HasPK ¶ added in v0.22.0
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
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.
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
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
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.
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
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
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.
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
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
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.
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 ¶
NewTestEndpoint returns new endpoint.
func (*Endpoint) HasPK ¶ added in v0.22.0
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
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.
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
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
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.
type HexString ¶
type HexString string
HexString is a hex-encoded binary data.
func HexFromBytes ¶
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 ¶
NewTestJob returns a default test job.
func (*Job) HasPK ¶ added in v0.22.0
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
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.
type JobBalanceData ¶
JobBalanceData is a data required for transfer jobs.
type JobCreateChannelData ¶
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 ¶
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
String returns a string representation of this struct or record.
type LogTopics ¶
LogTopics is a database/sql compatible type for ethereum 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 ¶
NewTestOffering returns new offering.
func (*Offering) HasPK ¶ added in v0.22.0
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
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.
type PWDGetSetter ¶
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 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) GetKey ¶ added in v1.0.1
func (s *PWDStorage) GetKey(acc *Account) (*ecdsa.PrivateKey, error)
GetKey returns private key of account.
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 (*Product) HasPK ¶ added in v0.22.0
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
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.
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
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
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.
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 ¶
NewTestSession returns new session.
func (*Session) HasPK ¶ added in v0.22.0
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
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.
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
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
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.
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.
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 ¶
NewTestTemplate returns new tempalte.
func (*Template) HasPK ¶ added in v0.22.0
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
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.
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.
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 (*User) HasPK ¶ added in v0.22.0
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
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.