Skip to content

Commit

Permalink
cleanup of logger and legacy dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mleku committed Jan 6, 2024
1 parent 54f9399 commit 0935381
Show file tree
Hide file tree
Showing 110 changed files with 539 additions and 529 deletions.
2 changes: 1 addition & 1 deletion cmd/replicatrd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/Hubmakerlabs/replicatr/cmd/replicatrd/replicatr"
"github.com/Hubmakerlabs/replicatr/pkg/eventstore/badger"
log2 "mleku.online/git/log"
log2 "github.com/Hubmakerlabs/replicatr/pkg/log"
)

const appName = "replicatr"
Expand Down
8 changes: 0 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module github.com/Hubmakerlabs/replicatr
go 1.21.5

require (
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/btcsuite/btcd/btcutil v1.1.3
github.com/davecgh/go-spew v1.1.1
github.com/dchest/blake256 v1.1.0
github.com/dgraph-io/badger/v4 v4.2.0
Expand All @@ -25,19 +23,13 @@ require (
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848
golang.org/x/net v0.18.0
lukechampine.com/frand v1.4.2
mleku.online/git/bech32 v1.0.3
mleku.online/git/ec v1.0.4
mleku.online/git/log v1.0.7
)

require (
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gobwas/pool v0.2.1 // indirect
Expand Down
76 changes: 0 additions & 76 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/ec/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"math/big"
"testing"

secp "mleku.online/git/ec/secp"
secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// setHex decodes the passed big-endian hex string into the internal field value
Expand Down Expand Up @@ -190,5 +190,5 @@ func BenchmarkParseCompressedPubKey(b *testing.B) {
pk, e = ParsePubKey(rawPk)
}
_ = pk
_ = err
_ = e
}
2 changes: 1 addition & 1 deletion pkg/ec/btcec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package btcec
// reverse the transform than to operate in affine coordinates.

import (
secp "mleku.online/git/ec/secp"
secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// KoblitzCurve provides an implementation for secp256k1 that fits the ECC
Expand Down
6 changes: 3 additions & 3 deletions pkg/ec/chaincfg/deployment_time_frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"time"

"mleku.online/git/ec/wire"
"github.com/Hubmakerlabs/replicatr/pkg/ec/wire"
)

var (
Expand Down Expand Up @@ -91,7 +91,7 @@ func (m *MedianTimeDeploymentStarter) HasStarted(blkHeader *wire.BlockHeader) (b

medianTime, e := m.blockClock.PastMedianTime(blkHeader)
if e != nil {
return false, err
return false, e
}

// We check both after and equal here as after will fail for equivalent
Expand Down Expand Up @@ -134,7 +134,7 @@ func (m *MedianTimeDeploymentEnder) HasEnded(blkHeader *wire.BlockHeader) (bool,

medianTime, e := m.blockClock.PastMedianTime(blkHeader)
if e != nil {
return false, err
return false, e
}

// We check both after and equal here as after will fail for equivalent
Expand Down
4 changes: 2 additions & 2 deletions pkg/ec/chaincfg/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package chaincfg
import (
"time"

"mleku.online/git/ec/chainhash"
"mleku.online/git/ec/wire"
"github.com/Hubmakerlabs/replicatr/pkg/ec/chainhash"
"github.com/Hubmakerlabs/replicatr/pkg/ec/wire"
)

// genesisCoinbaseTx is the coinbase transaction for the genesis blocks for
Expand Down
4 changes: 2 additions & 2 deletions pkg/ec/chaincfg/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"math/big"
"time"

"mleku.online/git/ec/chainhash"
"mleku.online/git/ec/wire"
"github.com/Hubmakerlabs/replicatr/pkg/ec/chainhash"
"github.com/Hubmakerlabs/replicatr/pkg/ec/wire"
)

var (
Expand Down
12 changes: 6 additions & 6 deletions pkg/ec/chainhash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (hash *Hash) UnmarshalJSON(input []byte) (e error) {
}

var sh string
e := json.Unmarshal(input, &sh)
e = json.Unmarshal(input, &sh)
if e != nil {
return e
}
Expand All @@ -145,9 +145,9 @@ func NewHash(newHash []byte) (*Hash, error) {
var sh Hash
e := sh.SetBytes(newHash)
if e != nil {
return nil, err
return nil, e
}
return &sh, err
return &sh, e
}

// TaggedHash implements the tagged hash scheme described in BIP-340. We use
Expand Down Expand Up @@ -186,7 +186,7 @@ func NewHashFromStr(hash string) (*Hash, error) {
ret := new(Hash)
e := Decode(ret, hash)
if e != nil {
return nil, err
return nil, e
}
return ret, nil
}
Expand All @@ -212,7 +212,7 @@ func Decode(dst *Hash, src string) (e error) {

// Hex decode the source bytes to a temporary destination.
var reversedHash Hash
_, e := hex.Decode(reversedHash[HashSize-hex.DecodedLen(len(srcBytes)):],
_, e = hex.Decode(reversedHash[HashSize-hex.DecodedLen(len(srcBytes)):],
srcBytes)
if e != nil {
return e
Expand All @@ -231,7 +231,7 @@ func Decode(dst *Hash, src string) (e error) {
// (i.e. represented as a bytes array) to a destination.
func decodeLegacy(dst *Hash, src []byte) (e error) {
var hashBytes []byte
e := json.Unmarshal(src, &hashBytes)
e = json.Unmarshal(src, &hashBytes)
if e != nil {
return e
}
Expand Down
13 changes: 7 additions & 6 deletions pkg/ec/chainhash/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bytes"
"encoding/hex"
"encoding/json"
"errors"
"testing"
)

Expand Down Expand Up @@ -182,8 +183,8 @@ func TestNewHashFromStr(t *testing.T) {
t.Logf("Running %d tests", len(tests))
for i, test := range tests {
result, e := NewHashFromStr(test.in)
if e != test.e {
t.Errorf(unexpectedErrStr, i, err, test.e)
if !errors.Is(e, test.err) {
t.Errorf(unexpectedErrStr, i, e, test.err)
continue
} else if e != nil {
// Got expected error. Move on to the next test.
Expand All @@ -203,18 +204,18 @@ func TestHashJsonMarshal(t *testing.T) {

hash, e := NewHashFromStr(hashStr)
if e != nil {
t.Errorf("NewHashFromStr error:%v, hashStr:%s", err, hashStr)
t.Errorf("NewHashFromStr error:%v, hashStr:%s", e, hashStr)
}

hashBytes, e := json.Marshal(hash)
if e != nil {
t.Errorf("Marshal json error:%v, hash:%v", err, hashBytes)
t.Errorf("Marshal json error:%v, hash:%v", e, hashBytes)
}

var newHash Hash
e = json.Unmarshal(hashBytes, &newHash)
if e != nil {
t.Errorf("Unmarshal json error:%v, hash:%v", err, hashBytes)
t.Errorf("Unmarshal json error:%v, hash:%v", e, hashBytes)
}

if !hash.IsEqual(&newHash) {
Expand All @@ -223,7 +224,7 @@ func TestHashJsonMarshal(t *testing.T) {

e = newHash.UnmarshalJSON(legacyHashStr)
if e != nil {
t.Errorf("Unmarshal legacy json error:%v, hash:%v", err, legacyHashStr)
t.Errorf("Unmarshal legacy json error:%v, hash:%v", e, legacyHashStr)
}

if !hash.IsEqual(&newHash) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ec/ciphering.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package btcec

import (
secp "mleku.online/git/ec/secp"
secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// GenerateSharedSecret generates a shared secret based on a secret key and a
Expand Down
4 changes: 2 additions & 2 deletions pkg/ec/curve.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package btcec
import (
"fmt"

secp "mleku.online/git/ec/secp"
secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// JacobianPoint is an element of the group formed by the secp256k1 curve in
Expand Down Expand Up @@ -85,7 +85,7 @@ func ParseJacobian(point []byte) (JacobianPoint, error) {

noncePk, e := secp.ParsePubKey(point)
if e != nil {
return JacobianPoint{}, err
return JacobianPoint{}, e
}
noncePk.AsJacobian(&result)

Expand Down
2 changes: 1 addition & 1 deletion pkg/ec/ecdsa/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"encoding/hex"
"testing"

"mleku.online/git/ec/secp"
"github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// hexToModNScalar converts the passed hex string into a ModNScalar and will
Expand Down
4 changes: 2 additions & 2 deletions pkg/ec/ecdsa/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"fmt"

"github.com/dchest/blake256"
"mleku.online/git/ec/ecdsa"
"mleku.online/git/ec/secp"
"github.com/Hubmakerlabs/replicatr/pkg/ec/ecdsa"
"github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// This example demonstrates signing a message with a secp256k1 secret key that
Expand Down
2 changes: 1 addition & 1 deletion pkg/ec/ecdsa/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package ecdsa
import (
"fmt"

"mleku.online/git/ec/secp"
"github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// References:
Expand Down
16 changes: 8 additions & 8 deletions pkg/ec/ecdsa/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

"github.com/dchest/blake256"

"mleku.online/git/ec/secp"
"github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// hexToBytes converts the passed hex string into bytes and will panic if there
Expand Down Expand Up @@ -206,9 +206,9 @@ func TestSignatureParsing(t *testing.T) {

for _, test := range tests {
_, e := ParseDERSignature(test.sig)
if !errors.Is(err, test.e) {
t.Errorf("%s mismatched err -- got %v, want %v", test.name, err,
test.e)
if !errors.Is(e, test.err) {
t.Errorf("%s mismatched err -- got %v, want %v", test.name, e,
test.err)
continue
}
}
Expand Down Expand Up @@ -979,9 +979,9 @@ func TestRecoverCompactErrors(t *testing.T) {

// Ensure the expected error is hit.
_, _, e := RecoverCompact(sig, hash)
if !errors.Is(err, test.e) {
t.Errorf("%s: mismatched err -- got %v, want %v", test.name, err,
test.e)
if !errors.Is(e, test.err) {
t.Errorf("%s: mismatched err -- got %v, want %v", test.name, e,
test.err)
continue
}
}
Expand Down Expand Up @@ -1031,7 +1031,7 @@ func TestSignAndRecoverCompactRandom(t *testing.T) {
gotPubKey, gotCompressed, e := RecoverCompact(gotSig, hash[:])
if e != nil {
t.Fatalf("unexpected err: %v\nsig: %x\nhash: %x\nsecret key: %x",
err, gotSig, hash, secKey.Serialize())
e, gotSig, hash, secKey.Serialize())
}
if gotCompressed != compressed {
t.Fatalf("unexpected compressed flag: %v\nsig: %x\nhash: %x\n"+
Expand Down
2 changes: 1 addition & 1 deletion pkg/ec/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package btcec

import (
secp "mleku.online/git/ec/secp"
secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// Error identifies an error related to public key cryptography using a
Expand Down
2 changes: 1 addition & 1 deletion pkg/ec/field.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package btcec

import secp "mleku.online/git/ec/secp"
import secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp"

// FieldVal implements optimized fixed-precision arithmetic over the secp256k1
// finite field. This means all arithmetic is performed modulo
Expand Down
2 changes: 1 addition & 1 deletion pkg/ec/modnscalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package btcec

import (
secp "mleku.online/git/ec/secp"
secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// ModNScalar implements optimized 256-bit constant-time fixed-precision
Expand Down
2 changes: 1 addition & 1 deletion pkg/ec/pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package btcec

import (
secp "mleku.online/git/ec/secp"
secp "github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// These constants define the lengths of serialized public keys.
Expand Down
8 changes: 4 additions & 4 deletions pkg/ec/schnorr/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"math/big"
"testing"

"mleku.online/git/ec"
"mleku.online/git/ec/secp"
"github.com/Hubmakerlabs/replicatr/pkg/ec"
"github.com/Hubmakerlabs/replicatr/pkg/ec/secp"
)

// hexToBytes converts the passed hex string into bytes and will panic if there
Expand Down Expand Up @@ -141,7 +141,7 @@ func BenchmarkSign(b *testing.B) {
}

testSig = sig
testErr = err
testErr = e
}

// BenchmarkSignRfc6979 benchmarks how long it takes to sign a message.
Expand All @@ -165,5 +165,5 @@ func BenchmarkSignRfc6979(b *testing.B) {
}

testSig = sig
testErr = err
testErr = e
}
2 changes: 1 addition & 1 deletion pkg/ec/schnorr/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package schnorr

import (
ecdsa_schnorr "mleku.online/git/ec/secp/schnorr"
ecdsa_schnorr "github.com/Hubmakerlabs/replicatr/pkg/ec/secp/schnorr"
)

// ErrorKind identifies a kind of error. It has full support for errors.Is
Expand Down
Loading

0 comments on commit 0935381

Please sign in to comment.