Skip to content

Commit 8f2cdf8

Browse files
authored
add notifier for all transactions (#30)
in preparation for hyperledger/fabric-x-committer#620. After that is merged, we can add an integration test to the SDK. Signed-off-by: Arne Rutjes <arne123@gmail.com>
1 parent bee11d3 commit 8f2cdf8

9 files changed

Lines changed: 462 additions & 1695 deletions

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,23 @@ To run the integration tests against a real Fabric-X network, see the [integrati
5252
| **integration** | Provides a couple of tests that exercise a large surface of the SDK. It provides some assurance on the internal consistency of the project. By default, the internal `fabrictest` fake network is used. It can also be pointed to real networks.|
5353
| **local** | Can be used to mock a Fabric backend for testing. Instead of submitting to an orderer, it can insert read/write sets directly in a local database. Some MVCC checks are provided, but should not be trusted to be 1:1 compatible with a real network. |
5454
| **network** | Has clients for peers and orderers, along with simple wrappers to submit a transaction and to synchronize a local database with a committer. |
55+
| **notification** | Subscribes to transaction events from the Fabric-X sidecar. `Notifier` tracks specific transactions you submitted; `AllTxStreamer` delivers a real-time feed of every committed transaction (optionally filtered by namespace or status). |
5556
| **state** | Provides a versioned insert-only database that can be used to construct a local world state. For example, an endorser could use it to perform actions on a recent state in order to generate a read/write set based on custom business logic. |
5657

58+
## Receiving transaction events
59+
60+
There are three complementary mechanisms for receiving committed transaction data, each suited to a different need:
61+
62+
| Mechanism | When to use |
63+
| --------- | ----------- |
64+
| `network.Synchronizer` | Maintain a local world state or full block history. Supports catch-up from any block height, reconnection, and liveness/readiness probes. Requires a signer. |
65+
| `notification.Notifier` | Know when a transaction *you* submitted commits or fails. Opens a bidirectional stream; you push txIDs to watch and receive back their status. |
66+
| `notification.AllTxStreamer` | React to *all* committed transactions (optionally filtered by namespace or status). Real-time feed only — no historical replay. Useful for audit logs, analytics, secondary indexes, or watching activity from other participants. |
67+
68+
All three can be used independently and composed in the same application. Both `Notifier` and `AllTxStreamer` are backed by the Fabric-X sidecar's Notification Service and require no signer.
69+
70+
---
71+
5772
For example, if you were building a block explorer, you would take the `network.Synchronizer`, load it with an `identity.Signer` and point to the committer sidecar. With help of the `blocks.Processor`, the `fabric(x).Parser` and a custom handler, you extract the information you want to store from the blocks that are coming in through the Synchronizer. Then you build your application around it.
5873

5974
If you were building a chaincode endorser, you would use the same elements, as well as the

go.mod

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,35 @@ tool (
1212
require (
1313
github.com/hyperledger/fabric-lib-go v1.1.3
1414
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.7
15-
github.com/hyperledger/fabric-x-common v0.2.4
15+
github.com/hyperledger/fabric-x-common v0.2.5
1616
google.golang.org/grpc v1.81.0
1717
google.golang.org/protobuf v1.36.11
1818
modernc.org/sqlite v1.48.0
1919
)
2020

2121
require (
22-
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
2322
github.com/IBM/idemix v0.0.2 // indirect
2423
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20260501050258-bb91d87b1252 // indirect
2524
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20260501050258-bb91d87b1252 // indirect
2625
github.com/IBM/idemix/bccsp/types v0.0.0-20260501050258-bb91d87b1252 // indirect
2726
github.com/IBM/mathlib v0.1.0 // indirect
2827
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
29-
github.com/Microsoft/go-winio v0.6.2 // indirect
3028
github.com/alecthomas/kingpin/v2 v2.4.0 // indirect
3129
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
32-
github.com/beorn7/perks v1.0.1 // indirect
3330
github.com/bits-and-blooms/bitset v1.24.4 // indirect
34-
github.com/bmatcuk/doublestar/v4 v4.9.2 // indirect
35-
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
36-
github.com/cespare/xxhash/v2 v2.3.0 // indirect
31+
github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect
3732
github.com/cockroachdb/errors v1.13.0 // indirect
3833
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
3934
github.com/cockroachdb/redact v1.1.8 // indirect
4035
github.com/consensys/gnark-crypto v0.20.1 // indirect
41-
github.com/containerd/log v0.1.0 // indirect
4236
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
43-
github.com/docker/docker v28.5.2+incompatible // indirect
44-
github.com/docker/go-connections v0.7.0 // indirect
45-
github.com/docker/go-units v0.5.0 // indirect
4637
github.com/dustin/go-humanize v1.0.1 // indirect
4738
github.com/fsnotify/fsnotify v1.10.1 // indirect
48-
github.com/fsouza/go-dockerclient v1.13.1 // indirect
4939
github.com/getsentry/sentry-go v0.46.2 // indirect
5040
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
5141
github.com/gogo/protobuf v1.3.2 // indirect
5242
github.com/golang/protobuf v1.5.4 // indirect
5343
github.com/google/addlicense v1.2.0 // indirect
54-
github.com/google/go-cmp v0.7.0 // indirect
5544
github.com/google/uuid v1.6.0 // indirect
5645
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
5746
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect
@@ -61,43 +50,19 @@ require (
6150
github.com/hyperledger/fabric-x v1.0.0 // indirect
6251
github.com/hyperledger/fabric-x-committer v1.0.0-alpha.1 // indirect
6352
github.com/inconshreveable/mousetrap v1.1.0 // indirect
64-
github.com/jackc/pgpassfile v1.0.0 // indirect
65-
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
66-
github.com/jackc/puddle/v2 v2.2.2 // indirect
6753
github.com/kilic/bls12-381 v0.1.0 // indirect
68-
github.com/klauspost/compress v1.18.6 // indirect
6954
github.com/kr/pretty v0.3.1 // indirect
7055
github.com/kr/text v0.2.0 // indirect
71-
github.com/mattn/go-isatty v0.0.20 // indirect
56+
github.com/mattn/go-isatty v0.0.22 // indirect
7257
github.com/miekg/pkcs11 v1.1.2 // indirect
7358
github.com/mitchellh/mapstructure v1.5.0 // indirect
74-
github.com/moby/docker-image-spec v1.3.1 // indirect
75-
github.com/moby/go-archive v0.2.0 // indirect
76-
github.com/moby/patternmatcher v0.6.1 // indirect
77-
github.com/moby/sys/sequential v0.6.0 // indirect
78-
github.com/moby/sys/user v0.4.0 // indirect
79-
github.com/moby/sys/userns v0.1.0 // indirect
80-
github.com/moby/term v0.5.2 // indirect
81-
github.com/morikuni/aec v1.1.0 // indirect
82-
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
8359
github.com/ncruces/go-strftime v1.0.0 // indirect
84-
github.com/nxadm/tail v1.4.11 // indirect
85-
github.com/onsi/ginkgo v1.16.5 // indirect
86-
github.com/onsi/gomega v1.38.2 // indirect
87-
github.com/opencontainers/go-digest v1.0.0 // indirect
88-
github.com/opencontainers/image-spec v1.1.1 // indirect
8960
github.com/pelletier/go-toml/v2 v2.3.1 // indirect
9061
github.com/pkg/errors v0.9.1 // indirect
9162
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
92-
github.com/prometheus/client_golang v1.23.2 // indirect
93-
github.com/prometheus/client_model v0.6.2 // indirect
94-
github.com/prometheus/common v0.67.5 // indirect
95-
github.com/prometheus/procfs v0.20.1 // indirect
9663
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
9764
github.com/rogpeppe/go-internal v1.14.1 // indirect
9865
github.com/sagikazarmark/locafero v0.12.0 // indirect
99-
github.com/sirupsen/logrus v1.9.4 // indirect
100-
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
10166
github.com/spf13/afero v1.15.0 // indirect
10267
github.com/spf13/cast v1.10.0 // indirect
10368
github.com/spf13/cobra v1.10.2 // indirect
@@ -106,21 +71,17 @@ require (
10671
github.com/stretchr/testify v1.11.1 // indirect
10772
github.com/subosito/gotenv v1.6.0 // indirect
10873
github.com/sykesm/zap-logfmt v0.0.4 // indirect
109-
github.com/tedsuo/ifrit v0.0.0-20230516164442-7862c310ad26 // indirect
11074
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
111-
github.com/yugabyte/pgx/v5 v5.7.6-yb-1 // indirect
11275
go.uber.org/multierr v1.11.0 // indirect
11376
go.uber.org/zap v1.28.0 // indirect
11477
go.yaml.in/yaml/v3 v3.0.4 // indirect
115-
golang.org/x/crypto v0.50.0 // indirect
116-
golang.org/x/net v0.53.0 // indirect
78+
golang.org/x/crypto v0.51.0 // indirect
79+
golang.org/x/net v0.54.0 // indirect
11780
golang.org/x/sync v0.20.0 // indirect
118-
golang.org/x/sys v0.43.0 // indirect
119-
golang.org/x/text v0.36.0 // indirect
120-
golang.org/x/time v0.15.0 // indirect
121-
google.golang.org/genproto/googleapis/api v0.0.0-20260504160031-60b97b32f348 // indirect
122-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348 // indirect
123-
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
81+
golang.org/x/sys v0.44.0 // indirect
82+
golang.org/x/text v0.37.0 // indirect
83+
google.golang.org/genproto/googleapis/api v0.0.0-20260511170946-3700d4141b60 // indirect
84+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260511170946-3700d4141b60 // indirect
12485
gopkg.in/yaml.v3 v3.0.1 // indirect
12586
modernc.org/libc v1.70.0 // indirect
12687
modernc.org/mathutil v1.7.1 // indirect

0 commit comments

Comments
 (0)