mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
core: do not write new dao elements into DB
It's useless work being done before it's actually needed. These (updated with new values) are going to be written with some kind of Put anyway, so writing them here is just a waste of time.
This commit is contained in:
parent
6896b40dee
commit
a9401e2ec7
2 changed files with 0 additions and 24 deletions
|
@ -55,9 +55,6 @@ func (dao *dao) GetAccountStateOrNew(hash util.Uint160) (*state.Account, error)
|
|||
return nil, err
|
||||
}
|
||||
account = state.NewAccount(hash)
|
||||
if err = dao.PutAccountState(account); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return account, nil
|
||||
}
|
||||
|
@ -151,9 +148,6 @@ func (dao *dao) GetUnspentCoinStateOrNew(hash util.Uint256) (*UnspentCoinState,
|
|||
unspent = &UnspentCoinState{
|
||||
states: []state.Coin{},
|
||||
}
|
||||
if err = dao.PutUnspentCoinState(hash, unspent); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return unspent, nil
|
||||
}
|
||||
|
@ -189,9 +183,6 @@ func (dao *dao) GetSpentCoinsOrNew(hash util.Uint256) (*SpentCoinState, error) {
|
|||
spent = &SpentCoinState{
|
||||
items: make(map[uint16]uint32),
|
||||
}
|
||||
if err = dao.PutSpentCoinState(hash, spent); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return spent, nil
|
||||
}
|
||||
|
@ -231,9 +222,6 @@ func (dao *dao) GetValidatorStateOrNew(publicKey *keys.PublicKey) (*state.Valida
|
|||
return nil, err
|
||||
}
|
||||
validatorState = &state.Validator{PublicKey: publicKey}
|
||||
if err = dao.PutValidatorState(validatorState); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return validatorState, nil
|
||||
|
||||
|
|
|
@ -45,9 +45,6 @@ func TestGetAccountStateOrNew_New(t *testing.T) {
|
|||
createdAccount, err := dao.GetAccountStateOrNew(hash)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, createdAccount)
|
||||
gotAccount, err := dao.GetAccountState(hash)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, createdAccount, gotAccount)
|
||||
}
|
||||
|
||||
func TestPutAndGetAccountStateOrNew(t *testing.T) {
|
||||
|
@ -102,9 +99,6 @@ func TestGetUnspentCoinStateOrNew_New(t *testing.T) {
|
|||
unspentCoinState, err := dao.GetUnspentCoinStateOrNew(hash)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, unspentCoinState)
|
||||
gotUnspentCoinState, err := dao.GetUnspentCoinState(hash)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, unspentCoinState, gotUnspentCoinState)
|
||||
}
|
||||
|
||||
func TestGetUnspentCoinState_Err(t *testing.T) {
|
||||
|
@ -132,9 +126,6 @@ func TestGetSpentCoinStateOrNew_New(t *testing.T) {
|
|||
spentCoinState, err := dao.GetSpentCoinsOrNew(hash)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, spentCoinState)
|
||||
gotSpentCoinState, err := dao.GetSpentCoinState(hash)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, spentCoinState, gotSpentCoinState)
|
||||
}
|
||||
|
||||
func TestPutAndGetSpentCoinState(t *testing.T) {
|
||||
|
@ -175,9 +166,6 @@ func TestGetValidatorStateOrNew_New(t *testing.T) {
|
|||
validatorState, err := dao.GetValidatorStateOrNew(publicKey)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, validatorState)
|
||||
gotValidatorState, err := dao.GetValidatorState(publicKey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, validatorState, gotValidatorState)
|
||||
}
|
||||
|
||||
func TestPutGetValidatorState(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue