chore: upstream more changes from v2 (#20387)

Co-authored-by: Matt Kocubinski <mkocubinski@gmail.com>
This commit is contained in:
Marko
2024-05-17 10:58:52 +00:00
committed by GitHub
co-authored by Matt Kocubinski
parent 92dafe6dac
commit d7cc6de7cc
39 changed files with 5432 additions and 8 deletions
Binary file not shown.
@@ -0,0 +1,41 @@
package main
import (
"context"
"fmt"
"github.com/hashicorp/go-plugin"
"cosmossdk.io/server/v2/streaming"
)
// StdoutPlugin is the implementation of the ABCIListener interface
// For Go plugins this is all that is required to process data sent over gRPC.
type StdoutPlugin struct {
BlockHeight int64
}
func (a *StdoutPlugin) ListenDeliverBlock(ctx context.Context, req streaming.ListenDeliverBlockRequest) error {
a.BlockHeight = req.BlockHeight
// process tx messages (i.e: sent to external system)
fmt.Printf("listen-finalize-block: block-height=%d req=%v res=%v", a.BlockHeight, req, nil)
return nil
}
func (a *StdoutPlugin) ListenStateChanges(ctx context.Context, changeSet []*streaming.StoreKVPair) error {
// process block commit messages (i.e: sent to external system)
fmt.Printf("listen-commit: block_height=%d res=%v data=%v", a.BlockHeight, changeSet, nil)
return nil
}
func main() {
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: streaming.Handshake,
Plugins: map[string]plugin.Plugin{
"abci": &streaming.ListenerGRPCPlugin{Impl: &StdoutPlugin{}},
},
// A non-nil value here enables gRPC serving for this streaming...
GRPCServer: plugin.DefaultGRPCServer,
})
}