@@ -61,11 +61,11 @@ func TestMergeBasics(t *testing.T) {
6161 }
6262 }
6363 // Add some (identical) layers on top
64- parent := newDiffLayer (emptyLayer {}, 1 , common.Hash {}, accounts , storage )
65- child := newDiffLayer (parent , 1 , common.Hash {}, accounts , storage )
66- child = newDiffLayer (child , 1 , common.Hash {}, accounts , storage )
67- child = newDiffLayer (child , 1 , common.Hash {}, accounts , storage )
68- child = newDiffLayer (child , 1 , common.Hash {}, accounts , storage )
64+ parent := newDiffLayer (emptyLayer {}, common.Hash {}, accounts , storage )
65+ child := newDiffLayer (parent , common.Hash {}, accounts , storage )
66+ child = newDiffLayer (child , common.Hash {}, accounts , storage )
67+ child = newDiffLayer (child , common.Hash {}, accounts , storage )
68+ child = newDiffLayer (child , common.Hash {}, accounts , storage )
6969 // And flatten
7070 merged := (child .flatten ()).(* diffLayer )
7171
@@ -122,7 +122,7 @@ func TestMergeDelete(t *testing.T) {
122122 }
123123
124124 // Add some flip-flopping layers on top
125- parent := newDiffLayer (emptyLayer {}, 1 , common.Hash {}, flip (), storage )
125+ parent := newDiffLayer (emptyLayer {}, common.Hash {}, flip (), storage )
126126 child := parent .Update (common.Hash {}, flop (), storage )
127127 child = child .Update (common.Hash {}, flip (), storage )
128128 child = child .Update (common.Hash {}, flop (), storage )
@@ -139,10 +139,6 @@ func TestMergeDelete(t *testing.T) {
139139 // And flatten
140140 merged := (child .flatten ()).(* diffLayer )
141141
142- // check number
143- if got , exp := merged .number , child .number ; got != exp {
144- t .Errorf ("merged layer: wrong number - exp %d got %d" , exp , got )
145- }
146142 if data , _ := merged .Account (h1 ); data == nil {
147143 t .Errorf ("merged layer: expected %x to be non-nil" , h1 )
148144 }
@@ -169,7 +165,7 @@ func TestInsertAndMerge(t *testing.T) {
169165 {
170166 var accounts = make (map [common.Hash ][]byte )
171167 var storage = make (map [common.Hash ]map [common.Hash ][]byte )
172- parent = newDiffLayer (emptyLayer {}, 1 , common.Hash {}, accounts , storage )
168+ parent = newDiffLayer (emptyLayer {}, common.Hash {}, accounts , storage )
173169 }
174170 {
175171 var accounts = make (map [common.Hash ][]byte )
@@ -178,7 +174,7 @@ func TestInsertAndMerge(t *testing.T) {
178174 accstorage := make (map [common.Hash ][]byte )
179175 storage [acc ] = accstorage
180176 storage [acc ][slot ] = []byte {0x01 }
181- child = newDiffLayer (parent , 2 , common.Hash {}, accounts , storage )
177+ child = newDiffLayer (parent , common.Hash {}, accounts , storage )
182178 }
183179 // And flatten
184180 merged := (child .flatten ()).(* diffLayer )
@@ -200,11 +196,12 @@ func (emptyLayer) Journal() error {
200196 panic ("implement me" )
201197}
202198
203- func (emptyLayer ) Info () ( uint64 , common. Hash ) {
204- return 0 , common. Hash {}
199+ func (emptyLayer ) Stale () bool {
200+ panic ( "implement me" )
205201}
206- func (emptyLayer ) Number () uint64 {
207- return 0
202+
203+ func (emptyLayer ) Root () common.Hash {
204+ return common.Hash {}
208205}
209206
210207func (emptyLayer ) Account (hash common.Hash ) (* Account , error ) {
@@ -227,19 +224,15 @@ func (emptyLayer) Storage(accountHash, storageHash common.Hash) ([]byte, error)
227224// BenchmarkSearch-6 500000 3723 ns/op (10k per layer, only top-level RLock()
228225func BenchmarkSearch (b * testing.B ) {
229226 // First, we set up 128 diff layers, with 1K items each
230-
231- blocknum := uint64 (0 )
232227 fill := func (parent snapshot ) * diffLayer {
233228 accounts := make (map [common.Hash ][]byte )
234229 storage := make (map [common.Hash ]map [common.Hash ][]byte )
235230
236231 for i := 0 ; i < 10000 ; i ++ {
237232 accounts [randomHash ()] = randomAccount ()
238233 }
239- blocknum ++
240- return newDiffLayer (parent , blocknum , common.Hash {}, accounts , storage )
234+ return newDiffLayer (parent , common.Hash {}, accounts , storage )
241235 }
242-
243236 var layer snapshot
244237 layer = emptyLayer {}
245238 for i := 0 ; i < 128 ; i ++ {
@@ -261,8 +254,6 @@ func BenchmarkSearch(b *testing.B) {
261254// BenchmarkSearchSlot-6 100000 14551 ns/op (when checking parent number using atomic)
262255func BenchmarkSearchSlot (b * testing.B ) {
263256 // First, we set up 128 diff layers, with 1K items each
264-
265- blocknum := uint64 (0 )
266257 accountKey := common.Hash {}
267258 storageKey := common .HexToHash ("0x1337" )
268259 accountRLP := randomAccount ()
@@ -278,16 +269,13 @@ func BenchmarkSearchSlot(b *testing.B) {
278269 accStorage [randomHash ()] = value
279270 storage [accountKey ] = accStorage
280271 }
281- blocknum ++
282- return newDiffLayer (parent , blocknum , common.Hash {}, accounts , storage )
272+ return newDiffLayer (parent , common.Hash {}, accounts , storage )
283273 }
284-
285274 var layer snapshot
286275 layer = emptyLayer {}
287276 for i := 0 ; i < 128 ; i ++ {
288277 layer = fill (layer )
289278 }
290-
291279 b .ResetTimer ()
292280 for i := 0 ; i < b .N ; i ++ {
293281 layer .Storage (accountKey , storageKey )
@@ -300,7 +288,7 @@ func BenchmarkSearchSlot(b *testing.B) {
300288// Without sorting and tracking accountlist
301289// BenchmarkFlatten-6 300 5511511 ns/op
302290func BenchmarkFlatten (b * testing.B ) {
303- fill := func (parent snapshot , blocknum int ) * diffLayer {
291+ fill := func (parent snapshot ) * diffLayer {
304292 accounts := make (map [common.Hash ][]byte )
305293 storage := make (map [common.Hash ]map [common.Hash ][]byte )
306294
@@ -317,7 +305,7 @@ func BenchmarkFlatten(b *testing.B) {
317305 }
318306 storage [accountKey ] = accStorage
319307 }
320- return newDiffLayer (parent , uint64 ( blocknum ), common.Hash {}, accounts , storage )
308+ return newDiffLayer (parent , common.Hash {}, accounts , storage )
321309 }
322310
323311 b .ResetTimer ()
@@ -327,7 +315,7 @@ func BenchmarkFlatten(b *testing.B) {
327315 var layer snapshot
328316 layer = emptyLayer {}
329317 for i := 1 ; i < 128 ; i ++ {
330- layer = fill (layer , i )
318+ layer = fill (layer )
331319 }
332320 b .StartTimer ()
333321
@@ -336,7 +324,6 @@ func BenchmarkFlatten(b *testing.B) {
336324 if ! ok {
337325 break
338326 }
339-
340327 layer = dl .flatten ()
341328 }
342329 b .StopTimer ()
@@ -351,7 +338,7 @@ func BenchmarkFlatten(b *testing.B) {
351338// BenchmarkJournal-6 1 1471373923 ns/ops
352339// BenchmarkJournal-6 1 1208083335 ns/op // bufio writer
353340func BenchmarkJournal (b * testing.B ) {
354- fill := func (parent snapshot , blocknum int ) * diffLayer {
341+ fill := func (parent snapshot ) * diffLayer {
355342 accounts := make (map [common.Hash ][]byte )
356343 storage := make (map [common.Hash ]map [common.Hash ][]byte )
357344
@@ -368,15 +355,14 @@ func BenchmarkJournal(b *testing.B) {
368355 }
369356 storage [accountKey ] = accStorage
370357 }
371- return newDiffLayer (parent , uint64 ( blocknum ), common.Hash {}, accounts , storage )
358+ return newDiffLayer (parent , common.Hash {}, accounts , storage )
372359 }
373-
374360 var layer snapshot
375361 layer = & diskLayer {
376362 journal : path .Join (os .TempDir (), "difflayer_journal.tmp" ),
377363 }
378364 for i := 1 ; i < 128 ; i ++ {
379- layer = fill (layer , i )
365+ layer = fill (layer )
380366 }
381367 b .ResetTimer ()
382368
0 commit comments