aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go9
-rw-r--r--state/pebble_backend.go6
-rw-r--r--state/pebble_state.go2
3 files changed, 15 insertions, 2 deletions
diff --git a/main.go b/main.go
index 91b96e3..2399ceb 100644
--- a/main.go
+++ b/main.go
@@ -41,9 +41,16 @@ func (t *TransactionSummary[IN, OUT]) Apply(ctx context.Context, key string, win
41func main() { 41func main() {
42 // init 42 // init
43 ctx := context.Background() 43 ctx := context.Background()
44 // memory backend
45 // backend := state.NewMemoryStateBackend(1)
46 // pebble backend
47 backend, err := state.NewPebbleStateBackend("./data_pebble", 1)
44 48
45 backend := state.NewMemoryStateBackend(1) 49 if err != nil {
50 panic(err)
51 }
46 52
53 defer backend.Close()
47 ctx = core.InjectStateBackend(ctx, backend) 54 ctx = core.InjectStateBackend(ctx, backend)
48 55
49 txList := []Transaction{ 56 txList := []Transaction{
diff --git a/state/pebble_backend.go b/state/pebble_backend.go
index fbb8d68..b510f8f 100644
--- a/state/pebble_backend.go
+++ b/state/pebble_backend.go
@@ -128,3 +128,9 @@ func (p *PebbleStateBackend) deserialize(stateID uint8) []byte {
128 } 128 }
129 return b 129 return b
130} 130}
131
132func (p *PebbleStateBackend) Close() error {
133 return p.db.Close()
134}
135
136
diff --git a/state/pebble_state.go b/state/pebble_state.go
index 3eeaa05..0b60deb 100644
--- a/state/pebble_state.go
+++ b/state/pebble_state.go
@@ -44,7 +44,7 @@ func (p *pebbleStateValue) Value(ctx context.Context) (any, error) {
44 44
45 res := core.GetBuffer(len(v)) 45 res := core.GetBuffer(len(v))
46 copy(res, v) 46 copy(res, v)
47 return v, nil 47 return res, nil
48} 48}
49 49
50func (p *pebbleStateValue) Clear(ctx context.Context) error { 50func (p *pebbleStateValue) Clear(ctx context.Context) error {