mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
1533674dad
Port https://github.com/ethereum/go-ethereum/pull/26003 --------- Co-authored-by: Mark Tyneway <mark.tyneway@gmail.com>
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
// Copyright 2022 The go-ethereum Authors
|
|
// This file is part of the go-ethereum library.
|
|
//
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Lesser General Public License for more details.
|
|
//
|
|
// 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/>.
|
|
|
|
package state
|
|
|
|
import (
|
|
"github.com/holiman/uint256"
|
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
)
|
|
|
|
// transientStorage is a representation of EIP-1153 "Transient Storage".
|
|
type transientStorage map[libcommon.Address]Storage
|
|
|
|
// newTransientStorage creates a new instance of a transientStorage.
|
|
func newTransientStorage() transientStorage {
|
|
return make(transientStorage)
|
|
}
|
|
|
|
// Set sets the transient-storage `value` for `key` at the given `addr`.
|
|
func (t transientStorage) Set(addr libcommon.Address, key libcommon.Hash, value uint256.Int) {
|
|
if _, ok := t[addr]; !ok {
|
|
t[addr] = make(Storage)
|
|
}
|
|
t[addr][key] = value
|
|
}
|
|
|
|
// Get gets the transient storage for `key` at the given `addr`.
|
|
func (t transientStorage) Get(addr libcommon.Address, key libcommon.Hash) uint256.Int {
|
|
val, ok := t[addr]
|
|
if !ok {
|
|
return *uint256.NewInt(0)
|
|
}
|
|
return val[key]
|
|
}
|