Skip to content

memoryMapFile

Source (upstream pre-purge) Current
File consensus/ethash/ethash.go ethash.go
Symbol memoryMapFile memoryMapFile
Ref dde2da0ef~1 etc/v1.17.3-full-node

ADAPT: reflect.SliceHeaderunsafe.Slice (#29067)

3-way merge — purge → getc ← upstream

pre-purgecore-geth
// memoryMapFile tries to memory map an already opened file descriptor.
func memoryMapFile(file *os.File, write bool) (mmap.MMap, []uint32, error) {
// Try to memory map the file
flag := mmap.RDONLY
if write {
flag = mmap.RDWR
}
mem, err := mmap.Map(file, flag, 0)
if err != nil {
return nil, nil, err
}
// The file is now memory-mapped. Create a []uint32 view of the file.
view := unsafe.Slice((*uint32)(unsafe.Pointer(&mem[0])), len(mem)/4)
return mem, view, nil
}
core-geth validation — **Identical** ✅ | | | |---|---| | File | [`ethash.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/consensus/ethash/ethash.go) | | Symbol | `memoryMapFile` | | Ref | `v1.12.20` |

← Consensus & Ethash