forked from TrueCloudLab/neoneo-go
core/tx: remove publickey indirection from assets and txes
It makes very little sense having pointers here, these structures MUST have some kind of key and this key is not gonna be wandering somewhere on its own. Fixes a part of #519.
This commit is contained in:
parent
5b6c5af704
commit
f1856bfa8b
9 changed files with 7 additions and 16 deletions
|
@ -43,7 +43,7 @@ type AssetState struct {
|
|||
Precision uint8
|
||||
FeeMode uint8
|
||||
FeeAddress util.Uint160
|
||||
Owner *keys.PublicKey
|
||||
Owner keys.PublicKey
|
||||
Admin util.Uint160
|
||||
Issuer util.Uint160
|
||||
Expiration uint32
|
||||
|
@ -63,7 +63,6 @@ func (a *AssetState) DecodeBinary(br *io.BinReader) {
|
|||
br.ReadLE(&a.FeeMode)
|
||||
br.ReadBytes(a.FeeAddress[:])
|
||||
|
||||
a.Owner = &keys.PublicKey{}
|
||||
a.Owner.DecodeBinary(br)
|
||||
br.ReadBytes(a.Admin[:])
|
||||
br.ReadBytes(a.Issuer[:])
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
|
||||
"github.com/CityOfZion/neo-go/pkg/core/storage"
|
||||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
||||
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
|
||||
"github.com/CityOfZion/neo-go/pkg/io"
|
||||
"github.com/CityOfZion/neo-go/pkg/util"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -20,7 +19,6 @@ func TestEncodeDecodeAssetState(t *testing.T) {
|
|||
Available: util.Fixed8(100),
|
||||
Precision: 0,
|
||||
FeeMode: feeMode,
|
||||
Owner: &keys.PublicKey{},
|
||||
Admin: randomUint160(),
|
||||
Issuer: randomUint160(),
|
||||
Expiration: 10,
|
||||
|
@ -47,7 +45,6 @@ func TestPutGetAssetState(t *testing.T) {
|
|||
Available: util.Fixed8(100),
|
||||
Precision: 8,
|
||||
FeeMode: feeMode,
|
||||
Owner: &keys.PublicKey{},
|
||||
Admin: randomUint160(),
|
||||
Issuer: randomUint160(),
|
||||
Expiration: 10,
|
||||
|
|
|
@ -1340,7 +1340,7 @@ func processStateTX(chainState *BlockChainState, tx *transaction.StateTX) error
|
|||
}
|
||||
|
||||
func processEnrollmentTX(chainState *BlockChainState, tx *transaction.EnrollmentTX) error {
|
||||
validatorState, err := chainState.validators.getAndUpdate(chainState.store, tx.PublicKey)
|
||||
validatorState, err := chainState.validators.getAndUpdate(chainState.store, &tx.PublicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -615,7 +615,7 @@ func (ic *interopContext) assetCreate(v *vm.VM) error {
|
|||
Name: name,
|
||||
Amount: amount,
|
||||
Precision: precision,
|
||||
Owner: owner,
|
||||
Owner: *owner,
|
||||
Admin: admin,
|
||||
Issuer: issuer,
|
||||
Expiration: ic.bc.BlockHeight() + DefaultAssetLifetime,
|
||||
|
|
|
@ -348,7 +348,7 @@ func createVMAndAssetState(t *testing.T) (*vm.VM, *AssetState, *interopContext)
|
|||
Precision: 1,
|
||||
FeeMode: 1,
|
||||
FeeAddress: randomUint160(),
|
||||
Owner: &keys.PublicKey{X: big.NewInt(1), Y: big.NewInt(1)},
|
||||
Owner: keys.PublicKey{X: big.NewInt(1), Y: big.NewInt(1)},
|
||||
Admin: randomUint160(),
|
||||
Issuer: randomUint160(),
|
||||
Expiration: 10,
|
||||
|
|
|
@ -12,12 +12,11 @@ import (
|
|||
// The way to cancel the registration is: Spend the deposit on the address of the PublicKey.
|
||||
type EnrollmentTX struct {
|
||||
// PublicKey of the validator.
|
||||
PublicKey *keys.PublicKey
|
||||
PublicKey keys.PublicKey
|
||||
}
|
||||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (tx *EnrollmentTX) DecodeBinary(r *io.BinReader) {
|
||||
tx.PublicKey = &keys.PublicKey{}
|
||||
tx.PublicKey.DecodeBinary(r)
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ type RegisterTX struct {
|
|||
Precision uint8
|
||||
|
||||
// Public key of the owner.
|
||||
Owner *keys.PublicKey
|
||||
Owner keys.PublicKey
|
||||
|
||||
Admin util.Uint160
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ func (tx *RegisterTX) DecodeBinary(br *io.BinReader) {
|
|||
br.ReadLE(&tx.Amount)
|
||||
br.ReadLE(&tx.Precision)
|
||||
|
||||
tx.Owner = &keys.PublicKey{}
|
||||
tx.Owner.DecodeBinary(br)
|
||||
|
||||
br.ReadBytes(tx.Admin[:])
|
||||
|
|
|
@ -21,7 +21,6 @@ func TestRegisterTX(t *testing.T) {
|
|||
Name: "this is some token I created",
|
||||
Amount: util.Fixed8FromInt64(1000000),
|
||||
Precision: 8,
|
||||
Owner: &keys.PublicKey{},
|
||||
Admin: someuint160,
|
||||
},
|
||||
}
|
||||
|
@ -58,7 +57,7 @@ func TestDecodeRegisterTXFromRawString(t *testing.T) {
|
|||
assert.Equal(t, "[{\"lang\":\"zh-CN\",\"name\":\"小蚁股\"},{\"lang\":\"en\",\"name\":\"AntShare\"}]", txData.Name)
|
||||
assert.Equal(t, util.Fixed8FromInt64(100000000), txData.Amount)
|
||||
assert.Equal(t, uint8(0), txData.Precision)
|
||||
assert.Equal(t, &keys.PublicKey{}, txData.Owner)
|
||||
assert.Equal(t, keys.PublicKey{}, txData.Owner)
|
||||
assert.Equal(t, "Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt", crypto.AddressFromUint160(txData.Admin))
|
||||
assert.Equal(t, "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b", tx.Hash().StringLE())
|
||||
|
||||
|
|
|
@ -98,7 +98,6 @@ func governingTokenTX() *transaction.Transaction {
|
|||
Name: "[{\"lang\":\"zh-CN\",\"name\":\"小蚁股\"},{\"lang\":\"en\",\"name\":\"AntShare\"}]",
|
||||
Amount: util.Fixed8FromInt64(100000000),
|
||||
Precision: 0,
|
||||
Owner: &keys.PublicKey{},
|
||||
Admin: admin,
|
||||
}
|
||||
|
||||
|
@ -121,7 +120,6 @@ func utilityTokenTX() *transaction.Transaction {
|
|||
Name: "[{\"lang\":\"zh-CN\",\"name\":\"小蚁币\"},{\"lang\":\"en\",\"name\":\"AntCoin\"}]",
|
||||
Amount: calculateUtilityAmount(),
|
||||
Precision: 8,
|
||||
Owner: &keys.PublicKey{},
|
||||
Admin: admin,
|
||||
}
|
||||
tx := &transaction.Transaction{
|
||||
|
|
Loading…
Reference in a new issue