mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-27 15:42:54 +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.
|
||||
func (bc *Blockchain) GetNatives() []state.NativeContract {
|
||||
res := make([]state.NativeContract, len(bc.contracts.Contracts))
|
||||
for i, c := range bc.contracts.Contracts {
|
||||
md := c.Metadata()
|
||||
res[i].ID = md.ID
|
||||
res[i].Hash = md.Hash
|
||||
res[i].Manifest = md.Manifest
|
||||
res[i].NEF = md.NEF
|
||||
res := make([]state.NativeContract, 0, len(bc.contracts.Contracts))
|
||||
for _, c := range bc.contracts.Contracts {
|
||||
res = append(res, c.Metadata().NativeContract)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
|
|
@ -99,12 +99,9 @@ type Contract interface {
|
|||
|
||||
// ContractMD represents native contract instance.
|
||||
type ContractMD struct {
|
||||
Manifest manifest.Manifest
|
||||
Name string
|
||||
ID int32
|
||||
NEF nef.File
|
||||
Hash util.Uint160
|
||||
Methods map[MethodAndArgCount]MethodAndPrice
|
||||
state.NativeContract
|
||||
Name string
|
||||
Methods map[MethodAndArgCount]MethodAndPrice
|
||||
}
|
||||
|
||||
// MethodAndArgCount represents method's signature.
|
||||
|
@ -117,10 +114,11 @@ type MethodAndArgCount struct {
|
|||
func NewContractMD(name string, id int32) *ContractMD {
|
||||
c := &ContractMD{
|
||||
Name: name,
|
||||
ID: id,
|
||||
Methods: make(map[MethodAndArgCount]MethodAndPrice),
|
||||
}
|
||||
|
||||
c.ID = id
|
||||
|
||||
// NEF is now stored in contract state and affects state dump.
|
||||
// Therefore values are taken from C# node.
|
||||
c.NEF.Header.Compiler = "neo-core-v3.0"
|
||||
|
|
|
@ -453,12 +453,7 @@ func (m *Management) OnPersist(ic *interop.Context) error {
|
|||
md := native.Metadata()
|
||||
|
||||
cs := &state.Contract{
|
||||
ContractBase: state.ContractBase{
|
||||
ID: md.ID,
|
||||
Hash: md.Hash,
|
||||
NEF: md.NEF,
|
||||
Manifest: md.Manifest,
|
||||
},
|
||||
ContractBase: md.ContractBase,
|
||||
}
|
||||
err := m.PutContractState(ic.DAO, cs)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue