Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
"github.com/CortexFoundation/CortexTheseus/rlp"
)

var big0 = big.NewInt(0)

type Code []byte

func (s Code) String() string {
Expand Down Expand Up @@ -434,53 +432,6 @@ func (s *stateObject) setBalance(amount *big.Int) {
s.data.Balance = amount
}

//func (s *stateObject) AddUpload(amount *big.Int) {
// if amount.Sign() == 0 {
// if s.empty() {
// s.touch()
// }
//
// return
// }
// s.SetUpload(new(big.Int).Add(s.Upload(), amount))
//}

func (s *stateObject) SubUpload(amount *big.Int) *big.Int {
if amount.Sign() == 0 {
return s.Upload()
}
var ret *big.Int = big0
if s.Upload().Cmp(amount) > 0 {
ret = new(big.Int).Sub(s.Upload(), amount)
}
s.SetUpload(ret)
return ret
}

func (s *stateObject) SetUpload(amount *big.Int) {
s.db.journal.append(uploadChange{
account: &s.address,
prev: new(big.Int).Set(s.data.Upload),
})
s.setUpload(amount)
}

func (s *stateObject) setNum(num *big.Int) {
s.data.Num = num
}

func (s *stateObject) SetNum(num *big.Int) {
s.db.journal.append(numChange{
account: &s.address,
prev: new(big.Int).Set(s.data.Num),
})
s.setNum(num)
}

func (s *stateObject) setUpload(amount *big.Int) {
s.data.Upload = amount
}

// Return the gas back to the origin. Used by the Virtual machine or Closures
func (s *stateObject) ReturnGas(gas *big.Int) {}

Expand Down Expand Up @@ -583,13 +534,6 @@ func (s *stateObject) Balance() *big.Int {
return s.data.Balance
}

func (s *stateObject) Upload() *big.Int {
return s.data.Upload
}
func (s *stateObject) Num() *big.Int {
return s.data.Num
}

func (s *stateObject) Nonce() uint64 {
return s.data.Nonce
}
Expand Down
66 changes: 66 additions & 0 deletions core/state/state_object_mdl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2023 The CortexTheseus Authors
// This file is part of the CortexFoundation library.
//
// The CortexFoundation 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 CortexFoundation 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 CortexFoundation library. If not, see <http://www.gnu.org/licenses/>.

package state

import (
"math/big"
)

var big0 = big.NewInt(0)

func (s *stateObject) SubUpload(amount *big.Int) *big.Int {
if amount.Sign() == 0 {
return s.Upload()
}
var ret *big.Int = big0
if s.Upload().Cmp(amount) > 0 {
ret = new(big.Int).Sub(s.Upload(), amount)
}
s.SetUpload(ret)
return ret
}

func (s *stateObject) SetUpload(amount *big.Int) {
s.db.journal.append(uploadChange{
account: &s.address,
prev: new(big.Int).Set(s.data.Upload),
})
s.setUpload(amount)
}

func (s *stateObject) setNum(num *big.Int) {
s.data.Num = num
}

func (s *stateObject) SetNum(num *big.Int) {
s.db.journal.append(numChange{
account: &s.address,
prev: new(big.Int).Set(s.data.Num),
})
s.setNum(num)
}

func (s *stateObject) setUpload(amount *big.Int) {
s.data.Upload = amount
}

func (s *stateObject) Upload() *big.Int {
return s.data.Upload
}
func (s *stateObject) Num() *big.Int {
return s.data.Num
}