53
vendor/github.com/status-im/status-go/common/dbsetup/db_setup.go
generated
vendored
Normal file
53
vendor/github.com/status-im/status-go/common/dbsetup/db_setup.go
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
package dbsetup
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
)
|
||||
|
||||
const InMemoryPath = ":memory:"
|
||||
|
||||
// The reduced number of kdf iterations (for performance reasons) which is
|
||||
// currently used for derivation of the database key
|
||||
// https://github.com/status-im/status-go/pull/1343
|
||||
// https://notes.status.im/i8Y_l7ccTiOYq09HVgoFwA
|
||||
const ReducedKDFIterationsNumber = 3200
|
||||
|
||||
type DatabaseInitializer interface {
|
||||
Initialize(path, password string, kdfIterationsNumber int) (*sql.DB, error)
|
||||
}
|
||||
|
||||
// GetDBFilename takes an instance of sql.DB and returns the filename of the "main" database
|
||||
func GetDBFilename(db *sql.DB) (string, error) {
|
||||
if db == nil {
|
||||
logger := log.New()
|
||||
logger.Warn("GetDBFilename was passed a nil pointer sql.DB")
|
||||
return "", nil
|
||||
}
|
||||
|
||||
var i, category, filename string
|
||||
rows, err := db.Query("PRAGMA database_list;")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
err = rows.Scan(&i, &category, &filename)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// The "main" database is the one we care about
|
||||
if category == "main" {
|
||||
return filename, nil
|
||||
}
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return "", errors.New("no main database found")
|
||||
}
|
||||
12
vendor/github.com/status-im/status-go/common/devices.go
generated
vendored
Normal file
12
vendor/github.com/status-im/status-go/common/devices.go
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
package common
|
||||
|
||||
import "runtime"
|
||||
|
||||
const (
|
||||
AndroidPlatform = "android"
|
||||
WindowsPlatform = "windows"
|
||||
)
|
||||
|
||||
func OperatingSystemIs(targetOS string) bool {
|
||||
return runtime.GOOS == targetOS
|
||||
}
|
||||
13
vendor/github.com/status-im/status-go/common/status_node_service.go
generated
vendored
Normal file
13
vendor/github.com/status-im/status-go/common/status_node_service.go
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
)
|
||||
|
||||
type StatusService interface {
|
||||
Start() error
|
||||
Stop() error
|
||||
Protocols() []p2p.Protocol
|
||||
APIs() []rpc.API
|
||||
}
|
||||
24
vendor/github.com/status-im/status-go/common/utils.go
generated
vendored
Normal file
24
vendor/github.com/status-im/status-go/common/utils.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/crypto"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
)
|
||||
|
||||
func RecoverKey(m *protobuf.ApplicationMetadataMessage) (*ecdsa.PublicKey, error) {
|
||||
if m.Signature == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
recoveredKey, err := crypto.SigToPub(
|
||||
crypto.Keccak256(m.Payload),
|
||||
m.Signature,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return recoveredKey, nil
|
||||
}
|
||||
Reference in New Issue
Block a user