Skip to content

Commit

Permalink
blocks/certifier: use sql database directly
Browse files Browse the repository at this point in the history
  • Loading branch information
dshulyak committed Feb 6, 2024
1 parent 9970eec commit 69bb187
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions blocks/certifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/spacemeshos/go-spacemesh/codec"
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/datastore"
"github.com/spacemeshos/go-spacemesh/hare/eligibility"
"github.com/spacemeshos/go-spacemesh/log"
"github.com/spacemeshos/go-spacemesh/p2p"
Expand Down Expand Up @@ -81,7 +80,7 @@ type Certifier struct {
stop func()
stopped atomic.Bool

db *datastore.CachedDB
db *sql.Database
oracle eligibility.Rolacle
signers map[types.NodeID]*signing.EdSigner
edVerifier *signing.EdVerifier
Expand All @@ -99,7 +98,7 @@ type Certifier struct {

// NewCertifier creates new block certifier.
func NewCertifier(
db *datastore.CachedDB,
db *sql.Database,
o eligibility.Rolacle,

v *signing.EdVerifier,
Expand Down
9 changes: 4 additions & 5 deletions blocks/certifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/spacemeshos/go-spacemesh/blocks/mocks"
"github.com/spacemeshos/go-spacemesh/codec"
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/datastore"
"github.com/spacemeshos/go-spacemesh/hare/eligibility"
"github.com/spacemeshos/go-spacemesh/log/logtest"
"github.com/spacemeshos/go-spacemesh/p2p/pubsub"
Expand All @@ -28,7 +27,7 @@ const defaultCnt = uint16(2)

type testCertifier struct {
*Certifier
db *datastore.CachedDB
db *sql.Database
mOracle *eligibility.MockRolacle
mPub *pubsubmock.MockPublisher
mClk *mocks.MocklayerClock
Expand All @@ -39,7 +38,7 @@ type testCertifier struct {
func newTestCertifier(t *testing.T, signers int) *testCertifier {
t.Helper()
types.SetLayersPerEpoch(3)
db := datastore.NewCachedDB(sql.InMemory(), logtest.New(t))
db := sql.InMemory()
ctrl := gomock.NewController(t)
mo := eligibility.NewMockRolacle(ctrl)
mp := pubsubmock.NewMockPublisher(ctrl)
Expand All @@ -66,7 +65,7 @@ func newTestCertifier(t *testing.T, signers int) *testCertifier {
}
}

func generateBlock(t *testing.T, db *datastore.CachedDB) *types.Block {
func generateBlock(t *testing.T, db sql.Executor) *types.Block {
t.Helper()
block := types.NewExistingBlock(
types.RandomBlockID(),
Expand Down Expand Up @@ -112,7 +111,7 @@ func genEncodedMsg(

func verifyCerts(
t *testing.T,
db *datastore.CachedDB,
db sql.Executor,
lid types.LayerID,
expected map[types.BlockID]bool,
) {
Expand Down

0 comments on commit 69bb187

Please sign in to comment.