Merge commit '5ed08c473' into merge/geth-v1.11.3
This commit is contained in:
@@ -636,7 +636,14 @@ func ReadReceipts(db ethdb.Reader, hash common.Hash, number uint64, config *para
|
||||
log.Error("Missing body but have receipt", "hash", hash, "number", number)
|
||||
return nil
|
||||
}
|
||||
if err := receipts.DeriveFields(config, hash, number, body.Transactions); err != nil {
|
||||
header := ReadHeader(db, hash, number)
|
||||
var baseFee *big.Int
|
||||
if header == nil {
|
||||
baseFee = big.NewInt(0)
|
||||
} else {
|
||||
baseFee = header.BaseFee
|
||||
}
|
||||
if err := receipts.DeriveFields(config, hash, number, baseFee, body.Transactions); err != nil {
|
||||
log.Error("Failed to derive block receipts fields", "hash", hash, "number", number, "err", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
//go:build arm64 || amd64
|
||||
//go:build (arm64 || amd64) && !openbsd
|
||||
|
||||
package rawdb
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//go:build !(arm64 || amd64)
|
||||
//go:build !((arm64 || amd64) && !openbsd)
|
||||
|
||||
package rawdb
|
||||
|
||||
|
||||
+14
-8
@@ -30,7 +30,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/prometheus/tsdb/fileutil"
|
||||
"github.com/gofrs/flock"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -75,7 +75,7 @@ type Freezer struct {
|
||||
|
||||
readonly bool
|
||||
tables map[string]*freezerTable // Data tables for storing everything
|
||||
instanceLock fileutil.Releaser // File-system lock to prevent double opens
|
||||
instanceLock *flock.Flock // File-system lock to prevent double opens
|
||||
closeOnce sync.Once
|
||||
}
|
||||
|
||||
@@ -104,11 +104,17 @@ func NewFreezer(datadir string, namespace string, readonly bool, maxTableSize ui
|
||||
return nil, errSymlinkDatadir
|
||||
}
|
||||
}
|
||||
flockFile := filepath.Join(datadir, "FLOCK")
|
||||
if err := os.MkdirAll(filepath.Dir(flockFile), 0755); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Leveldb uses LOCK as the filelock filename. To prevent the
|
||||
// name collision, we use FLOCK as the lock name.
|
||||
lock, _, err := fileutil.Flock(filepath.Join(datadir, "FLOCK"))
|
||||
if err != nil {
|
||||
lock := flock.New(flockFile)
|
||||
if locked, err := lock.TryLock(); err != nil {
|
||||
return nil, err
|
||||
} else if !locked {
|
||||
return nil, errors.New("locking failed")
|
||||
}
|
||||
// Open all the supported data tables
|
||||
freezer := &Freezer{
|
||||
@@ -124,12 +130,12 @@ func NewFreezer(datadir string, namespace string, readonly bool, maxTableSize ui
|
||||
for _, table := range freezer.tables {
|
||||
table.Close()
|
||||
}
|
||||
lock.Release()
|
||||
lock.Unlock()
|
||||
return nil, err
|
||||
}
|
||||
freezer.tables[name] = table
|
||||
}
|
||||
|
||||
var err error
|
||||
if freezer.readonly {
|
||||
// In readonly mode only validate, don't truncate.
|
||||
// validate also sets `freezer.frozen`.
|
||||
@@ -142,7 +148,7 @@ func NewFreezer(datadir string, namespace string, readonly bool, maxTableSize ui
|
||||
for _, table := range freezer.tables {
|
||||
table.Close()
|
||||
}
|
||||
lock.Release()
|
||||
lock.Unlock()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -165,7 +171,7 @@ func (f *Freezer) Close() error {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
if err := f.instanceLock.Release(); err != nil {
|
||||
if err := f.instanceLock.Unlock(); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user