···42}
4344// store and plc must be able to share transaction objects
45-func NewDIDPLCApplication(treeDB dbm.DB, indexDB dbm.DB, clearData func(), snapshotDirectory string) (*DIDPLCApplication, *transaction.Factory, plc.PLC, func(), error) {
46 mkTree := func() *iavl.MutableTree {
47 // Using SpeedDefault appears to cause the processing time for ExecuteOperation to double on average
48 // Using SpeedBetterCompression appears to cause the processing time to double again
···68 runnerContext: context.Background(),
69 tree: tree,
70 indexDB: indexDB,
71- txFactory: transaction.NewFactory(tree, indexDB, store.Tree.NextOperationSequence),
72 snapshotDirectory: snapshotDirectory,
73 aocsByPLC: make(map[string]*authoritativeOperationsCache),
74 }
7500000076 d.fullyClearApplicationData = func() error {
77 // we assume this is called in a single-threaded context, which should be a safe assumption since we'll only call this during snapshot import
78 // and CometBFT only calls one ABCI method at a time
···8586 *d.tree = *mkTree()
8788- d.txFactory = transaction.NewFactory(tree, indexDB, store.Tree.NextOperationSequence)
00089 return nil
90 }
91
···42}
4344// store and plc must be able to share transaction objects
45+func NewDIDPLCApplication(treeDB dbm.DB, indexDB transaction.ExtendedDB, clearData func(), snapshotDirectory string) (*DIDPLCApplication, *transaction.Factory, plc.PLC, func(), error) {
46 mkTree := func() *iavl.MutableTree {
47 // Using SpeedDefault appears to cause the processing time for ExecuteOperation to double on average
48 // Using SpeedBetterCompression appears to cause the processing time to double again
···68 runnerContext: context.Background(),
69 tree: tree,
70 indexDB: indexDB,
071 snapshotDirectory: snapshotDirectory,
72 aocsByPLC: make(map[string]*authoritativeOperationsCache),
73 }
7475+ d.txFactory, err = transaction.NewFactory(tree, indexDB, store.Tree.NextOperationSequence, store.Tree.BuildDIDBloomFilter)
76+ if err != nil {
77+ return nil, nil, nil, func() {}, stacktrace.Propagate(err, "")
78+ }
79+80+81 d.fullyClearApplicationData = func() error {
82 // we assume this is called in a single-threaded context, which should be a safe assumption since we'll only call this during snapshot import
83 // and CometBFT only calls one ABCI method at a time
···9091 *d.tree = *mkTree()
9293+ d.txFactory, err = transaction.NewFactory(tree, indexDB, store.Tree.NextOperationSequence, store.Tree.BuildDIDBloomFilter)
94+ if err != nil {
95+ return stacktrace.Propagate(err, "")
96+ }
97 return nil
98 }
99
···110 // this tree is just to avoid a nil pointer when creating a transaction with the factory
111 // the transactions don't actually get used
112 tree := iavl.NewMutableTree(dbm.NewMemDB(), 128, false, iavl.NewNopLogger())
113- txFactory := transaction.NewFactory(tree, nil, store.Tree.NextOperationSequence)
0114115 t.Run("Test Resolve DID", func(t *testing.T) {
116 server, err := NewServer(txFactory, mockPLC, nil, "tcp://127.0.0.1:8080", 15*time.Second)
···110 // this tree is just to avoid a nil pointer when creating a transaction with the factory
111 // the transactions don't actually get used
112 tree := iavl.NewMutableTree(dbm.NewMemDB(), 128, false, iavl.NewNopLogger())
113+ txFactory, err := transaction.NewFactory(tree, nil, store.Tree.NextOperationSequence, store.Tree.BuildDIDBloomFilter)
114+ require.NoError(t, err)
115116 t.Run("Test Resolve DID", func(t *testing.T) {
117 server, err := NewServer(txFactory, mockPLC, nil, "tcp://127.0.0.1:8080", 15*time.Second)
+2-2
plc/impl.go
···29func (plc *plcImpl) ValidateOperation(ctx context.Context, readTx transaction.Read, did string, opBytes []byte) error {
30 timestamp := syntax.Datetime(readTx.Timestamp().Format(types.ActualAtprotoDatetimeLayout))
3132- // TODO set true to false only while importing old ops
33 _, err := plc.validator.Validate(ctx, readTx, timestamp, did, opBytes, true)
34 if err != nil {
35 return stacktrace.Propagate(err, "operation failed validation")
···41func (plc *plcImpl) ExecuteOperation(ctx context.Context, tx transaction.Write, did string, opBytes []byte) error {
42 timestamp := syntax.Datetime(tx.Timestamp().Format(types.ActualAtprotoDatetimeLayout))
4344- // TODO set true to false only while importing old ops
45 effects, err := plc.validator.Validate(ctx, tx.Downgrade(), timestamp, did, opBytes, true)
46 if err != nil {
47 return stacktrace.Propagate(err, "operation failed validation")
···29func (plc *plcImpl) ValidateOperation(ctx context.Context, readTx transaction.Read, did string, opBytes []byte) error {
30 timestamp := syntax.Datetime(readTx.Timestamp().Format(types.ActualAtprotoDatetimeLayout))
3132+ // TODO set last parameter to true only while importing old ops
33 _, err := plc.validator.Validate(ctx, readTx, timestamp, did, opBytes, true)
34 if err != nil {
35 return stacktrace.Propagate(err, "operation failed validation")
···41func (plc *plcImpl) ExecuteOperation(ctx context.Context, tx transaction.Write, did string, opBytes []byte) error {
42 timestamp := syntax.Datetime(tx.Timestamp().Format(types.ActualAtprotoDatetimeLayout))
4344+ // TODO set last parameter to true only while importing old ops
45 effects, err := plc.validator.Validate(ctx, tx.Downgrade(), timestamp, did, opBytes, true)
46 if err != nil {
47 return stacktrace.Propagate(err, "operation failed validation")