@@ -10,8 +10,6 @@ import (
10
10
"fmt"
11
11
"sync"
12
12
13
- "github.com/prometheus/client_golang/prometheus"
14
-
15
13
"go.opentelemetry.io/otel/attribute"
16
14
17
15
oteltrace "go.opentelemetry.io/otel/trace"
@@ -27,6 +25,7 @@ import (
27
25
"github.com/ava-labs/avalanchego/utils"
28
26
"github.com/ava-labs/avalanchego/utils/math"
29
27
"github.com/ava-labs/avalanchego/utils/set"
28
+ "github.com/prometheus/client_golang/prometheus"
30
29
)
31
30
32
31
const (
53
52
errSameRoot = errors .New ("start and end root are the same" )
54
53
)
55
54
56
- type Config struct {
57
- // The number of changes to the database that we store in memory in order to
58
- // serve change proofs.
59
- HistoryLength int
60
- NodeCacheSize int
61
- // If [Reg] is nil, metrics are collected locally but not exported through
62
- // Prometheus.
63
- // This may be useful for testing.
64
- Reg prometheus.Registerer
65
- Tracer trace.Tracer
66
- }
67
-
68
- type MerkleDB interface {
69
- database.Database
70
- Trie
71
-
55
+ type ChangeProofer interface {
72
56
// GetChangeProof returns a proof for a subset of the key/value changes in key range
73
57
// [start, end] that occurred between [startRootID] and [endRootID].
74
58
// Returns at most [maxLength] key/value pairs.
@@ -105,7 +89,9 @@ type MerkleDB interface {
105
89
106
90
// CommitChangeProof commits the key/value pairs within the [proof] to the db.
107
91
CommitChangeProof (ctx context.Context , proof * ChangeProof ) error
92
+ }
108
93
94
+ type RangeProofer interface {
109
95
// GetRangeProofAtRoot returns a proof for the key/value pairs in this trie within the range
110
96
// [start, end] when the root of the trie was [rootID].
111
97
GetRangeProofAtRoot (
@@ -121,6 +107,27 @@ type MerkleDB interface {
121
107
CommitRangeProof (ctx context.Context , start []byte , proof * RangeProof ) error
122
108
}
123
109
110
+ type MerkleDB interface {
111
+ database.Database
112
+ Trie
113
+ MerkleRootGetter
114
+ ProofGetter
115
+ ChangeProofer
116
+ RangeProofer
117
+ }
118
+
119
+ type Config struct {
120
+ // The number of changes to the database that we store in memory in order to
121
+ // serve change proofs.
122
+ HistoryLength int
123
+ NodeCacheSize int
124
+ // If [Reg] is nil, metrics are collected locally but not exported through
125
+ // Prometheus.
126
+ // This may be useful for testing.
127
+ Reg prometheus.Registerer
128
+ Tracer trace.Tracer
129
+ }
130
+
124
131
// merkleDB can only be edited by committing changes from a trieView.
125
132
type merkleDB struct {
126
133
// Must be held when reading/writing fields.
0 commit comments