@@ -31,7 +31,7 @@ import (
3131func  ReadDatabaseVersion (db  ethdb.KeyValueReader ) * uint64  {
3232	var  version  uint64 
3333
34- 	enc , _  :=  db .Get (databaseVerisionKey )
34+ 	enc , _  :=  db .Get (databaseVersionKey )
3535	if  len (enc ) ==  0  {
3636		return  nil 
3737	}
@@ -48,7 +48,7 @@ func WriteDatabaseVersion(db ethdb.KeyValueWriter, version uint64) {
4848	if  err  !=  nil  {
4949		log .Crit ("Failed to encode database version" , "err" , err )
5050	}
51- 	if  err  =  db .Put (databaseVerisionKey , enc ); err  !=  nil  {
51+ 	if  err  =  db .Put (databaseVersionKey , enc ); err  !=  nil  {
5252		log .Crit ("Failed to store the database version" , "err" , err )
5353	}
5454}
@@ -81,22 +81,24 @@ func WriteChainConfig(db ethdb.KeyValueWriter, hash common.Hash, cfg *params.Cha
8181	}
8282}
8383
84- // ucmList  is a list of unclean-shutdown-markers, for rlp-encoding to the 
84+ // crashList  is a list of unclean-shutdown-markers, for rlp-encoding to the 
8585// database 
86- type  ucmList  struct  {
86+ type  crashList  struct  {
8787	Discarded  uint64    // how many ucs have we deleted 
8888	Recent     []uint64  // unix timestamps of 10 latest unclean shutdowns 
8989}
9090
91- // UpdateUncleanShutdownMarker appends a new unclean shutdown marker and returns 
91+ const  crashesToKeep  =  10 
92+ 
93+ // PushUncleanShutdownMarker appends a new unclean shutdown marker and returns 
9294// the previous data 
9395// - a list of timestamps 
9496// - a count of how many old unclean-shutdowns have been discarded 
95- func  UpdateUncleanShutdownMarker (db  ethdb.KeyValueStore ) ([]uint64 , uint64 , error ) {
96- 	var  uncleanShutdowns  ucmList 
97+ func  PushUncleanShutdownMarker (db  ethdb.KeyValueStore ) ([]uint64 , uint64 , error ) {
98+ 	var  uncleanShutdowns  crashList 
9799	// Read old data 
98100	if  data , err  :=  db .Get (uncleanShutdownKey ); err  !=  nil  {
99- 		log .Warn ("Error reading USM " , "error" , err )
101+ 		log .Warn ("Error reading unclean shutdown markers " , "error" , err )
100102	} else  if  err  :=  rlp .DecodeBytes (data , & uncleanShutdowns ); err  !=  nil  {
101103		return  nil , 0 , err 
102104	}
@@ -105,8 +107,8 @@ func UpdateUncleanShutdownMarker(db ethdb.KeyValueStore) ([]uint64, uint64, erro
105107	copy (previous , uncleanShutdowns .Recent )
106108	// Add a new (but cap it) 
107109	uncleanShutdowns .Recent  =  append (uncleanShutdowns .Recent , uint64 (time .Now ().Unix ()))
108- 	if  l  :=  len (uncleanShutdowns .Recent ); l  >  11  {
109- 		uncleanShutdowns .Recent  =  uncleanShutdowns .Recent [l - 11 :]
110+ 	if  l  :=  len (uncleanShutdowns .Recent ); l  >  crashesToKeep + 1  {
111+ 		uncleanShutdowns .Recent  =  uncleanShutdowns .Recent [l - crashesToKeep - 1 :]
110112		uncleanShutdowns .Discarded ++ 
111113	}
112114	// And save it again 
@@ -118,14 +120,14 @@ func UpdateUncleanShutdownMarker(db ethdb.KeyValueStore) ([]uint64, uint64, erro
118120	return  previous , discarded , nil 
119121}
120122
121- // ClearUncleanShutdowMarker  removes the last unclean shutdown marker 
122- func  ClearUncleanShutdowMarker (db  ethdb.KeyValueStore ) {
123- 	var  uncleanShutdowns  ucmList 
123+ // PopUncleanShutdownMarker  removes the last unclean shutdown marker 
124+ func  PopUncleanShutdownMarker (db  ethdb.KeyValueStore ) {
125+ 	var  uncleanShutdowns  crashList 
124126	// Read old data 
125127	if  data , err  :=  db .Get (uncleanShutdownKey ); err  !=  nil  {
126- 		log .Warn ("Error reading USM " , "error" , err )
128+ 		log .Warn ("Error reading unclean shutdown markers " , "error" , err )
127129	} else  if  err  :=  rlp .DecodeBytes (data , & uncleanShutdowns ); err  !=  nil  {
128- 		log .Error ("Error reading USM " , "error" , err ) // Should mos def _not_ happen 
130+ 		log .Error ("Error decoding unclean shutdown markers " , "error" , err ) // Should mos def _not_ happen 
129131	}
130132	if  l  :=  len (uncleanShutdowns .Recent ); l  >  0  {
131133		uncleanShutdowns .Recent  =  uncleanShutdowns .Recent [:l - 1 ]
0 commit comments