Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
This commit is contained in:
parent
dcec726d24
commit
1228f82ce1
2
.gitignore
vendored
2
.gitignore
vendored
@ -52,6 +52,8 @@ vagrant
|
||||
.dir-locals.el
|
||||
.vscode
|
||||
|
||||
.venv
|
||||
|
||||
# Depinject & Graphviz
|
||||
dependency-graph.png
|
||||
debug_container.dot
|
||||
|
||||
@ -169,12 +169,6 @@ just trying the examples, you can skip ahead to the [Testing](#testing) section.
|
||||
make proto-gen
|
||||
```
|
||||
|
||||
* stdout plugin; from inside the `store/` dir, run:
|
||||
|
||||
```shell
|
||||
go build -o streaming/abci/examples/stdout/stdout streaming/abci/examples/stdout/stdout.go
|
||||
```
|
||||
|
||||
* file plugin (writes to `~/`); from inside the `store/` dir, run:
|
||||
|
||||
```shell
|
||||
@ -185,12 +179,6 @@ go build -o streaming/abci/examples/file/file streaming/abci/examples/file/file.
|
||||
|
||||
Export a plugin from one of the Go or Python examples.
|
||||
|
||||
* stdout plugin
|
||||
|
||||
```shell
|
||||
export COSMOS_SDK_ABCI="{path to}/cosmos-sdk/store/streaming/abci/examples/stdout/stdout"
|
||||
```
|
||||
|
||||
* file plugin (writes to ~/)
|
||||
|
||||
```shell
|
||||
|
||||
Binary file not shown.
@ -1,43 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
|
||||
streamingabci "cosmossdk.io/store/streaming/abci"
|
||||
store "cosmossdk.io/store/types"
|
||||
)
|
||||
|
||||
// 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) ListenFinalizeBlock(ctx context.Context, req abci.RequestFinalizeBlock, res abci.ResponseFinalizeBlock) error {
|
||||
a.BlockHeight = req.Height
|
||||
// process tx messages (i.e: sent to external system)
|
||||
fmt.Printf("listen-finalize-block: block-height=%d req=%v res=%v", a.BlockHeight, req, res)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *StdoutPlugin) ListenCommit(ctx context.Context, res abci.ResponseCommit, changeSet []*store.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, res, changeSet)
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
plugin.Serve(&plugin.ServeConfig{
|
||||
HandshakeConfig: streamingabci.Handshake,
|
||||
Plugins: map[string]plugin.Plugin{
|
||||
"abci": &streamingabci.ListenerGRPCPlugin{Impl: &StdoutPlugin{}},
|
||||
},
|
||||
|
||||
// A non-nil value here enables gRPC serving for this streaming...
|
||||
GRPCServer: plugin.DefaultGRPCServer,
|
||||
})
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user