feat: Waku v2 bridge

Issue #12610
This commit is contained in:
Michal Iskierko
2023-11-12 13:29:38 +01:00
parent 56e7bd01ca
commit 6d31343205
6716 changed files with 1982502 additions and 5891 deletions

View 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")
}

View File

@@ -0,0 +1,12 @@
package common
import "runtime"
const (
AndroidPlatform = "android"
WindowsPlatform = "windows"
)
func OperatingSystemIs(targetOS string) bool {
return runtime.GOOS == targetOS
}

View 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
View 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
}