Skip to content

Commit 23913cf

Browse files
committed
remove unused code
1 parent 2e6c33b commit 23913cf

File tree

1 file changed

+0
-75
lines changed

1 file changed

+0
-75
lines changed

core/state/statedb.go

-75
Original file line numberDiff line numberDiff line change
@@ -1553,81 +1553,6 @@ func (s *StateDB) Commit(failPostCommitFunc func(), postCommitFuncs ...func() er
15531553
return root, diffLayer, nil
15541554
}
15551555

1556-
// GenerateDiffLayer generates block's DiffLayer after executing the block's txs.
1557-
// Attention, the DiffLayer returned include no Receipts, whose accounts' storage root
1558-
// is empty, whose BlockHash and Number field is empty, should further process by caller.
1559-
func (s *StateDB) GenerateDiffLayer() *types.DiffLayer {
1560-
if s.snap == nil {
1561-
return nil
1562-
}
1563-
1564-
for addr := range s.stateObjectsPending {
1565-
if obj := s.stateObjects[addr]; !obj.deleted {
1566-
// The snapshot storage map for the object
1567-
var storage map[string][]byte
1568-
obj.finalise(false)
1569-
for key, value := range obj.pendingStorage {
1570-
// Skip noop changes, persist actual changes
1571-
if value == obj.originStorage[key] {
1572-
continue
1573-
}
1574-
obj.originStorage[key] = value
1575-
1576-
var v []byte
1577-
if (value != common.Hash{}) {
1578-
// Encoding []byte cannot fail, ok to ignore the error.
1579-
v, _ = rlp.EncodeToBytes(common.TrimLeftZeroes(value[:]))
1580-
}
1581-
1582-
obj.db.snapMux.Lock()
1583-
if storage == nil {
1584-
// Retrieve the old storage map, if available, create a new one otherwise
1585-
if storage = obj.db.snapStorage[obj.address]; storage == nil {
1586-
storage = make(map[string][]byte)
1587-
obj.db.snapStorage[obj.address] = storage
1588-
}
1589-
}
1590-
storage[string(key[:])] = v // v will be nil if value is 0x00
1591-
obj.db.snapMux.Unlock()
1592-
}
1593-
1594-
if !obj.deleted {
1595-
s.snapMux.Lock()
1596-
// The storage root hasn't been intermediate, pass empty storage root here.
1597-
s.snapAccounts[obj.address] = snapshot.SlimAccountRLP(obj.data.Nonce, obj.data.Balance, common.Hash{}, obj.data.CodeHash)
1598-
s.snapMux.Unlock()
1599-
}
1600-
}
1601-
}
1602-
1603-
var diffLayer = &types.DiffLayer{}
1604-
for addr := range s.stateObjectsDirty {
1605-
if obj := s.stateObjects[addr]; !obj.deleted {
1606-
if obj.code != nil && obj.dirtyCode {
1607-
diffLayer.Codes = append(diffLayer.Codes, types.DiffCode{
1608-
Hash: common.BytesToHash(obj.CodeHash()),
1609-
Code: obj.code,
1610-
})
1611-
}
1612-
}
1613-
}
1614-
1615-
diffLayer.Destructs, diffLayer.Accounts, diffLayer.Storages = s.SnapToDiffLayer()
1616-
sort.SliceStable(diffLayer.Codes, func(i, j int) bool {
1617-
return diffLayer.Codes[i].Hash.Hex() < diffLayer.Codes[j].Hash.Hex()
1618-
})
1619-
sort.SliceStable(diffLayer.Destructs, func(i, j int) bool {
1620-
return diffLayer.Destructs[i].Hex() < (diffLayer.Destructs[j].Hex())
1621-
})
1622-
sort.SliceStable(diffLayer.Accounts, func(i, j int) bool {
1623-
return diffLayer.Accounts[i].Account.Hex() < diffLayer.Accounts[j].Account.Hex()
1624-
})
1625-
sort.SliceStable(diffLayer.Storages, func(i, j int) bool {
1626-
return diffLayer.Storages[i].Account.Hex() < diffLayer.Storages[j].Account.Hex()
1627-
})
1628-
return diffLayer
1629-
}
1630-
16311556
func (s *StateDB) DiffLayerToSnap(diffLayer *types.DiffLayer) (map[common.Address]struct{}, map[common.Address][]byte, map[common.Address]map[string][]byte, error) {
16321557
snapDestructs := make(map[common.Address]struct{})
16331558
snapAccounts := make(map[common.Address][]byte)

0 commit comments

Comments
 (0)