Skip to content

Commit 1d52068

Browse files
authored
Add Close method to cache writer (#24)
* Add Close method to cache writer * Update to Go 1.19
1 parent 4a99302 commit 1d52068

File tree

7 files changed

+17
-7
lines changed

7 files changed

+17
-7
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
name: CI
22

33
env:
4-
go-version: "1.18"
4+
go-version: "1.19"
55

66
# Controls when the action will run. Triggers the workflow on push or pull request
77
# events but only for the develop branch
88
on:
9-
push:
10-
branches: [develop]
119
pull_request:
10+
push:
1211
branches: [develop]
1312

1413
jobs:

cache/cache.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ func (c *Writer) SetHash(hashFunc HashFunc) {
6060
c.hash = hashFunc
6161
}
6262

63+
func (c *Writer) Close() {
64+
for _, layer := range c.layers {
65+
layer.Close()
66+
}
67+
}
68+
6369
// GetReader returns a cache reader that can be passed into GenerateProof. It first flushes the layer writers to support
6470
// layer writers that have internal buffers that may not be reflected in the reader until flushed. After flushing, this
6571
// method validates the structure of the cache, including that a base layer is cached.

cache/cachingpolicies_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package cache
33
import (
44
"testing"
55

6-
"github.com/spacemeshos/merkle-tree/cache/readwriters"
76
"github.com/stretchr/testify/require"
7+
8+
"github.com/spacemeshos/merkle-tree/cache/readwriters"
89
)
910

1011
func TestMakeMemoryReadWriterFactory(t *testing.T) {

merkle.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55

66
"github.com/minio/sha256-simd"
7+
78
"github.com/spacemeshos/merkle-tree/shared"
89
)
910

merkle_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import (
77
"testing"
88
"time"
99

10+
"github.com/stretchr/testify/require"
11+
1012
"github.com/spacemeshos/merkle-tree"
1113
"github.com/spacemeshos/merkle-tree/cache"
12-
"github.com/stretchr/testify/require"
1314
)
1415

1516
var (

proving_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/spacemeshos/merkle-tree/cache"
1110
"github.com/stretchr/testify/require"
11+
12+
"github.com/spacemeshos/merkle-tree/cache"
1213
)
1314

1415
/*

validation_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/spacemeshos/merkle-tree/cache"
87
"github.com/stretchr/testify/require"
8+
9+
"github.com/spacemeshos/merkle-tree/cache"
910
)
1011

1112
func TestValidatePartialTree(t *testing.T) {

0 commit comments

Comments
 (0)