Documentation ¶
Index ¶
- Constants
- 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 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 MinDeposit(offering *Offering) uint64
- 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 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 ValidatePassword(hash Base64String, password, salt string) error
- type Account
- type Base64BigInt
- type Base64String
- type Channel
- type Contract
- type DBConfig
- type EncryptedKeyFunc
- type Endpoint
- type EndpointUI
- type EthTx
- type HexString
- type Job
- type JobBalanceData
- type JobCreateChannelData
- type JobData
- type JobEndpointCreateData
- type JobEthLog
- type JobPublishData
- type JobTopUpChannelData
- type LogEvent
- type LogTopics
- type Offering
- type PWDGetSetter
- type PWDGetter
- type PWDSetter
- type PWDStorage
- type Product
- type Session
- type Setting
- type StaticPWDStorage
- type Template
- type TestData
- type TestFixture
- type ToPrivateKeyFunc
- type User
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" )
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" JobClientEndpointRestore = "clientEndpointRestore" JobClientAfterOfferingMsgBCPublish = "clientAfterOfferingMsgBCPublish" JobClientAfterOfferingPopUp = "clientAfterOfferingPopUp" JobClientAfterOfferingDelete = "clientAfterOfferingDelete" JobClientCompleteServiceTransition = "completeServiceTransition" 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" JobPreAccountAddBalance = "preAccountAddBalance" JobAfterAccountAddBalance = "afterAccountAddBalance" JobPreAccountReturnBalance = "preAccountReturnBalance" JobAfterAccountReturnBalance = "afterAccountReturnBalance" JobAccountUpdateBalances = "accountUpdateBalances" JobDecrementCurrentSupply = "decrementCurrentSupply" JobIncrementCurrentSupply = "incrementCurrentSupply" )
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 ( 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 ( SettingAppVersion = "system.version.app" SettingBlockLimit = "eth.event.blocklimit" SettingDefaultGasPrice = "eth.default.gasprice" SettingFreshBlocks = "eth.event.freshblocks" SettingOfferingAutoPopUp = "offering.autopopup" SettingLastProcessedBlock = "eth.event.lastProcessedBlock" 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" )
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 ¶
This section is empty.
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 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-init-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 MinDeposit ¶
MinDeposit calculates minimal deposit required to accept the offering.
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 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 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.
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.
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.
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.
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.
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
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.
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 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.
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"` 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.
type PWDGetSetter ¶
PWDGetSetter can get and set password to storage.
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.
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.
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.
type StaticPWDStorage ¶
type StaticPWDStorage string
StaticPWDStorage returns static static password, can't be rewritten.
func (*StaticPWDStorage) Get ¶
func (s *StaticPWDStorage) Get() string
Get returns stored static password.
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.
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 }
TestFixture encapsulates a typical set of DB objects useful for testing.
func NewEthTestFixture ¶
func NewEthTestFixture(t *testing.T, db *reform.DB, account *truffle.TestAccount) *TestFixture
NewEthTestFixture creates a new ethereum test fixture.
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.