@@ -25,7 +25,6 @@ import (
25
25
"github.com/ethereum/go-ethereum/common"
26
26
"github.com/ethereum/go-ethereum/ethdb"
27
27
"github.com/ethereum/go-ethereum/log"
28
- "github.com/ethereum/go-ethereum/params"
29
28
)
30
29
31
30
const (
@@ -87,22 +86,6 @@ func (f *chainFreezer) Close() error {
87
86
return f .AncientStore .Close ()
88
87
}
89
88
90
- // readHeadNumber returns the number of chain head block. 0 is returned if the
91
- // block is unknown or not available yet.
92
- func (f * chainFreezer ) readHeadNumber (db ethdb.KeyValueReader ) uint64 {
93
- hash := ReadHeadBlockHash (db )
94
- if hash == (common.Hash {}) {
95
- log .Error ("Head block is not reachable" )
96
- return 0
97
- }
98
- number := ReadHeaderNumber (db , hash )
99
- if number == nil {
100
- log .Error ("Number of head block is missing" )
101
- return 0
102
- }
103
- return * number
104
- }
105
-
106
89
// readFinalizedNumber returns the number of finalized block. 0 is returned
107
90
// if the block is unknown or not available yet.
108
91
func (f * chainFreezer ) readFinalizedNumber (db ethdb.KeyValueReader ) uint64 {
@@ -118,24 +101,13 @@ func (f *chainFreezer) readFinalizedNumber(db ethdb.KeyValueReader) uint64 {
118
101
return * number
119
102
}
120
103
121
- // freezeThreshold returns the threshold for chain freezing. It's determined
122
- // by formula: max(finality, HEAD-params.FullImmutabilityThreshold).
104
+ // freezeThreshold returns the threshold for chain freezing.
123
105
func (f * chainFreezer ) freezeThreshold (db ethdb.KeyValueReader ) (uint64 , error ) {
124
- var (
125
- head = f .readHeadNumber (db )
126
- final = f .readFinalizedNumber (db )
127
- headLimit uint64
128
- )
129
- if head > params .FullImmutabilityThreshold {
130
- headLimit = head - params .FullImmutabilityThreshold
131
- }
132
- if final == 0 && headLimit == 0 {
106
+ final := f .readFinalizedNumber (db )
107
+ if final == 0 {
133
108
return 0 , errors .New ("freezing threshold is not available" )
134
109
}
135
- if final > headLimit {
136
- return final , nil
137
- }
138
- return headLimit , nil
110
+ return final , nil
139
111
}
140
112
141
113
// freeze is a background thread that periodically checks the blockchain for any
0 commit comments