Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - blocks/certifier: use sql database directly #5546

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ func (app *App) initServices(ctx context.Context) error {
app.Config.Certificate.LayerBuffer = app.Config.Tortoise.Zdist
app.Config.Certificate.NumLayersToKeep = app.Config.Tortoise.Zdist * 2
app.certifier = blocks.NewCertifier(
app.cachedDB,
app.db,
app.hOracle,
app.edVerifier,
app.host,
Expand Down