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

Add DBSync Module #118

Merged
merged 24 commits into from
Apr 24, 2023
Merged
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
4 changes: 4 additions & 0 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,7 @@ func (cli *grpcClient) VerifyVoteExtension(ctx context.Context, params *types.Re
func (cli *grpcClient) FinalizeBlock(ctx context.Context, params *types.RequestFinalizeBlock) (*types.ResponseFinalizeBlock, error) {
return cli.client.FinalizeBlock(ctx, types.ToRequestFinalizeBlock(params).GetFinalizeBlock(), grpc.WaitForReady(true))
}

func (cli *grpcClient) LoadLatest(ctx context.Context, params *types.RequestLoadLatest) (*types.ResponseLoadLatest, error) {
return cli.client.LoadLatest(ctx, types.ToRequestLoadLatest(params).GetLoadLatest(), grpc.WaitForReady(true))
}
27 changes: 25 additions & 2 deletions abci/client/mocks/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ func (cli *socketClient) FinalizeBlock(ctx context.Context, req *types.RequestFi
return res.GetFinalizeBlock(), nil
}

func (cli *socketClient) LoadLatest(ctx context.Context, req *types.RequestLoadLatest) (*types.ResponseLoadLatest, error) {
res, err := cli.doRequest(ctx, types.ToRequestLoadLatest(req))
if err != nil {
return nil, err
}
return res.GetLoadLatest(), nil
}

//----------------------------------------

func resMatchesReq(req *types.Request, res *types.Response) (ok bool) {
Expand Down
9 changes: 8 additions & 1 deletion abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package types

import "context"

//go:generate ../../scripts/mockery_generate.sh Application
// Application is an interface that enables any finite, deterministic state machine
// to be driven by a blockchain-based replication engine via the ABCI.
//
//go:generate ../../scripts/mockery_generate.sh Application
type Application interface {
// Info/Query Connection
Info(context.Context, *RequestInfo) (*ResponseInfo, error) // Return application info
Expand All @@ -31,6 +32,8 @@ type Application interface {
OfferSnapshot(context.Context, *RequestOfferSnapshot) (*ResponseOfferSnapshot, error) // Offer a snapshot to the application
LoadSnapshotChunk(context.Context, *RequestLoadSnapshotChunk) (*ResponseLoadSnapshotChunk, error) // Load a snapshot chunk
ApplySnapshotChunk(context.Context, *RequestApplySnapshotChunk) (*ResponseApplySnapshotChunk, error) // Apply a shapshot chunk
// Notify application to load latest application state (e.g. after DBSync finishes)
LoadLatest(context.Context, *RequestLoadLatest) (*ResponseLoadLatest, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a small comment for what this interface do? Like the above ones?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

}

//-------------------------------------------------------
Expand Down Expand Up @@ -119,3 +122,7 @@ func (BaseApplication) FinalizeBlock(_ context.Context, req *RequestFinalizeBloc
TxResults: txs,
}, nil
}

func (BaseApplication) LoadLatest(_ context.Context, _ *RequestLoadLatest) (*ResponseLoadLatest, error) {
return &ResponseLoadLatest{}, nil
}
12 changes: 12 additions & 0 deletions abci/types/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ func ToRequestFinalizeBlock(req *RequestFinalizeBlock) *Request {
}
}

func ToRequestLoadLatest(req *RequestLoadLatest) *Request {
return &Request{
Value: &Request_LoadLatest{req},
}
}

//----------------------------------------

func ToResponseException(errStr string) *Response {
Expand Down Expand Up @@ -226,3 +232,9 @@ func ToResponseFinalizeBlock(res *ResponseFinalizeBlock) *Response {
Value: &Response_FinalizeBlock{res},
}
}

func ToResponseLoadLatest(res *ResponseLoadLatest) *Response {
return &Response{
Value: &Response_LoadLatest{res},
}
}
27 changes: 25 additions & 2 deletions abci/types/mocks/application.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading