mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-02-18 11:15:36 +00:00
interop: reuse state.Native
in ContractMD
This commit is contained in:
parent
6ca7b4b966
commit
02ca3d3dfd
3 changed files with 9 additions and 20 deletions
|
@ -1245,13 +1245,9 @@ func (bc *Blockchain) GetNativeContractScriptHash(name string) (util.Uint160, er
|
||||||
|
|
||||||
// GetNatives returns list of native contracts.
|
// GetNatives returns list of native contracts.
|
||||||
func (bc *Blockchain) GetNatives() []state.NativeContract {
|
func (bc *Blockchain) GetNatives() []state.NativeContract {
|
||||||
res := make([]state.NativeContract, len(bc.contracts.Contracts))
|
res := make([]state.NativeContract, 0, len(bc.contracts.Contracts))
|
||||||
for i, c := range bc.contracts.Contracts {
|
for _, c := range bc.contracts.Contracts {
|
||||||
md := c.Metadata()
|
res = append(res, c.Metadata().NativeContract)
|
||||||
res[i].ID = md.ID
|
|
||||||
res[i].Hash = md.Hash
|
|
||||||
res[i].Manifest = md.Manifest
|
|
||||||
res[i].NEF = md.NEF
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,11 +99,8 @@ type Contract interface {
|
||||||
|
|
||||||
// ContractMD represents native contract instance.
|
// ContractMD represents native contract instance.
|
||||||
type ContractMD struct {
|
type ContractMD struct {
|
||||||
Manifest manifest.Manifest
|
state.NativeContract
|
||||||
Name string
|
Name string
|
||||||
ID int32
|
|
||||||
NEF nef.File
|
|
||||||
Hash util.Uint160
|
|
||||||
Methods map[MethodAndArgCount]MethodAndPrice
|
Methods map[MethodAndArgCount]MethodAndPrice
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,10 +114,11 @@ type MethodAndArgCount struct {
|
||||||
func NewContractMD(name string, id int32) *ContractMD {
|
func NewContractMD(name string, id int32) *ContractMD {
|
||||||
c := &ContractMD{
|
c := &ContractMD{
|
||||||
Name: name,
|
Name: name,
|
||||||
ID: id,
|
|
||||||
Methods: make(map[MethodAndArgCount]MethodAndPrice),
|
Methods: make(map[MethodAndArgCount]MethodAndPrice),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.ID = id
|
||||||
|
|
||||||
// NEF is now stored in contract state and affects state dump.
|
// NEF is now stored in contract state and affects state dump.
|
||||||
// Therefore values are taken from C# node.
|
// Therefore values are taken from C# node.
|
||||||
c.NEF.Header.Compiler = "neo-core-v3.0"
|
c.NEF.Header.Compiler = "neo-core-v3.0"
|
||||||
|
|
|
@ -453,12 +453,7 @@ func (m *Management) OnPersist(ic *interop.Context) error {
|
||||||
md := native.Metadata()
|
md := native.Metadata()
|
||||||
|
|
||||||
cs := &state.Contract{
|
cs := &state.Contract{
|
||||||
ContractBase: state.ContractBase{
|
ContractBase: md.ContractBase,
|
||||||
ID: md.ID,
|
|
||||||
Hash: md.Hash,
|
|
||||||
NEF: md.NEF,
|
|
||||||
Manifest: md.Manifest,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
err := m.PutContractState(ic.DAO, cs)
|
err := m.PutContractState(ic.DAO, cs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue