schema

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2018 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SQL Statements
	PragmaUserVersionSQL                    = "pragma user_version = 0;"
	CreateTableConfigSQL                    = "create table config (key text primary key not null, value blob);"
	CreateTableFollowersSQL                 = "create table followers (peerID text primary key not null, proof blob);"
	CreateTableFollowingSQL                 = "create table following (peerID text primary key not null);"
	CreateTableOfflineMessagesSQL           = "create table offlinemessages (url text primary key not null, timestamp integer, message blob);"
	CreateTablePointersSQL                  = "" /* 135-byte string literal not displayed */
	CreateTableKeysSQL                      = "create table keys (scriptAddress text primary key not null, purpose integer, keyIndex integer, used integer, key text);"
	CreateTableUnspentTransactionOutputsSQL = "create table utxos (outpoint text primary key not null, value integer, height integer, scriptPubKey text, watchOnly integer);"
	CreateTableSpentTransactionOutputsSQL   = "" /* 162-byte string literal not displayed */
	CreateTableTransactionsSQL              = "" /* 129-byte string literal not displayed */
	CreateTableTransactionMetadataSQL       = "" /* 132-byte string literal not displayed */
	CreateTableInventorySQL                 = "create table inventory (invID text primary key not null, slug text, variantIndex integer, count integer);"
	CreateIndexInventorySQL                 = "create index index_inventory on inventory (slug);"
	CreateTablePurchasesSQL                 = "" /* 508-byte string literal not displayed */
	CreateIndexPurchasesSQL                 = "create index index_purchases on purchases (paymentAddr, timestamp);"
	CreateTableSalesSQL                     = "" /* 426-byte string literal not displayed */
	CreateIndexSalesSQL                     = "create index index_sales on sales (paymentAddr, timestamp);"
	CreatedTableWatchedScriptsSQL           = "create table watchedscripts (scriptPubKey text primary key not null);"
	CreateTableDisputedCasesSQL             = "" /* 470-byte string literal not displayed */
	CreateIndexDisputedCasesSQL             = "create index index_cases on cases (timestamp);"
	CreateTableChatSQL                      = "" /* 148-byte string literal not displayed */
	CreateIndexChatSQL                      = "create index index_chat on chat (peerID, subject, read, timestamp);"
	CreateTableNotificationsSQL             = "" /* 136-byte string literal not displayed */
	CreateIndexNotificationsSQL             = "create index index_notifications on notifications (read, type, timestamp);"
	CreateTableCouponsSQL                   = "create table coupons (slug text, code text, hash text);"
	CreateIndexCouponsSQL                   = "create index index_coupons on coupons (slug);"
	CreateTableModeratedStoresSQL           = "create table moderatedstores (peerID text primary key not null);"

	// Configuration defaults
	DataPushNodeOne = "QmY8puEnVx66uEet64gAf4VZRo7oUyMCwG6KdB9KM92EGQ"
	DataPushNodeTwo = "QmPPg2qeF3n2KvTRXRZLaTwHCw8JxzF4uZK93RfMoDvf2o"

	BootstrapNodeTestnet_BrooklynFlea     = "/ip4/165.227.117.91/tcp/4001/ipfs/Qmaa6De5QYNqShzPb9SGSo8vLmoUte8mnWgzn4GYwzuUYA"
	BootstrapNodeTestnet_Shipshewana      = "/ip4/46.101.221.165/tcp/4001/ipfs/QmVAQYg7ygAWTWegs8HSV2kdW1MqW8WMrmpqKG1PQtkgTC"
	BootstrapNodeDefault_LeMarcheSerpette = "/ip4/107.170.133.32/tcp/4001/ipfs/QmUZRGLhcKXF1JyuaHgKm23LvqcoMYwtb9jmh8CkP4og3K"
	BootstrapNodeDefault_BrixtonVillage   = "/ip4/139.59.174.197/tcp/4001/ipfs/QmZfTbnpvPwxCjpCG3CXJ7pfexgkBZ2kgChAiRJrTK1HsM"
	BootstrapNodeDefault_Johari           = "/ip4/139.59.6.222/tcp/4001/ipfs/QmRDcEDK9gSViAevCHiE6ghkaBCU7rTuQj4BDpmCzRvRYg"
	BootstrapNodeDefault_DuoSearch        = "/ip4/46.101.198.170/tcp/4001/ipfs/QmePWxsFT9wY3QuukgVDB7XZpqdKhrqJTHTXU7ECLDWJqX"
)
View Source
const (
	CurrentSchemaVersion  = "8"
	IdentityKeyLength     = 4096
	DefaultSeedPassphrase = "Secret Passphrase"
)

Variables

View Source
var (
	// Errors
	ErrorEmptyMnemonic = errors.New("mnemonic string must not be empty")
)
View Source
var MalformedConfigError error = errors.New("Config file is malformed")

Functions

func CreateIdentityKey

func CreateIdentityKey(mnemonic string) ([]byte, error)

IdentityKey will return a []byte representing a node's verifiable identity based on the provided mnemonic string. If the string is empty, it will return an error

func GenerateTempPath

func GenerateTempPath() string

GenerateTempPath returns a string path representing the location where it is okay to store temporary data. No structure or created or deleted as part of this operation.

func GetDropboxApiToken

func GetDropboxApiToken(cfgBytes []byte) (string, error)

func GetRepublishInterval

func GetRepublishInterval(cfgBytes []byte) (time.Duration, error)

func GetTestnetBootstrapAddrs

func GetTestnetBootstrapAddrs(cfgBytes []byte) ([]string, error)

func InitializeDatabaseSQL

func InitializeDatabaseSQL(encryptionPassword string) string

InitializeDatabaseSQL returns the executeable SQL string which initializes the database schema. It assumes the target is an empty SQLite3 database which supports encryption via the `PRAGMA key` statement

func MustDefaultConfig

func MustDefaultConfig() *config.Config

func MustNewCustomSchemaManager

func MustNewCustomSchemaManager(ctx SchemaContext) *openbazaarSchemaManager

MustNewCustomSchemaManager returns a new schema manager or panics

func NewCustomSchemaManager

func NewCustomSchemaManager(ctx SchemaContext) (*openbazaarSchemaManager, error)

NewCustomSchemaManger allows a custom SchemaContext to be provided

func NewMnemonic

func NewMnemonic() (string, error)

NewMnemonic will return a randomly-generated BIP-39 compliant mnemonic

func NewSchemaManager

func NewSchemaManager() (*openbazaarSchemaManager, error)

NewSchemaManager returns a service that handles the data storage directory required during runtime. This service also ensures no errors can be produced at runtime after initial creation. An error may be produced if the SchemaManager is unable to verify the availability of the data storage directory.

func OpenbazaarPathTransform

func OpenbazaarPathTransform(basePath string, testModeEnabled bool) (path string, err error)

DefaultPathTransform accepts a string path representing the location where application data can be stored and returns a string representing the location where OpenBazaar prefers to store its schema on the filesystem relative to that path. If the path cannot be transformed, an error will be returned

func PragmaKey

func PragmaKey(password string) string

PragmaKey returns the executable SQL string to encrypt the database

Types

type APIConfig

type APIConfig struct {
	Authenticated bool
	AllowedIPs    []string
	Username      string
	Password      string
	CORS          *string
	Enabled       bool
	HTTPHeaders   map[string]interface{}
	SSL           bool
	SSLCert       string
	SSLKey        string
}

func GetAPIConfig

func GetAPIConfig(cfgBytes []byte) (*APIConfig, error)

type CoinConfig

type CoinConfig struct {
	Type             string
	API              string
	APITestnet       string
	MaxFee           int
	FeeAPI           string
	HighFeeDefault   int
	MediumFeeDefault int
	LowFeeDefault    int
}

type DataSharing

type DataSharing struct {
	AcceptStoreRequests bool
	PushTo              []string
}

func GetDataSharing

func GetDataSharing(cfgBytes []byte) (*DataSharing, error)

type ResolverConfig

type ResolverConfig struct {
	Id  string `json:".id"`
	Eth string `json:".eth"`
}

func GetResolverConfig

func GetResolverConfig(cfgBytes []byte) (*ResolverConfig, error)

type SchemaContext

type SchemaContext struct {
	DataPath        string
	IdentityKey     []byte
	Mnemonic        string
	OS              string
	SchemaPassword  string
	TestModeEnabled bool
}

SchemaContext are the parameters which the SchemaManager derive its source of truth. When their zero values are provided, a reasonable default will be assumed during runtime.

type TorConfig

type TorConfig struct {
	Password   string
	TorControl string
}

func GetTorConfig

func GetTorConfig(cfgBytes []byte) (*TorConfig, error)

type WalletConfig

type WalletConfig struct {
	Type             string
	Binary           string
	MaxFee           int
	FeeAPI           string
	HighFeeDefault   int
	MediumFeeDefault int
	LowFeeDefault    int
	TrustedPeer      string
}

func GetWalletConfig

func GetWalletConfig(cfgBytes []byte) (*WalletConfig, error)

type WalletsConfig

type WalletsConfig struct {
	BTC CoinConfig `json:"BTC"`
	BCH CoinConfig `json:"BCH"`
	LTC CoinConfig `json:"LTC"`
	ZEC CoinConfig `json:"ZEC"`
}

func GetWalletsConfig

func GetWalletsConfig(cfgBytes []byte) (*WalletsConfig, error)

Jump to

Keyboard shortcuts

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