native: implement HF-based update
A part of #3213. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
83fdcc8568
commit
d62fad1268
19 changed files with 416 additions and 105 deletions
|
@ -118,7 +118,6 @@ func newOracle() *Oracle {
|
|||
ContractMD: *interop.NewContractMD(nativenames.Oracle, oracleContractID),
|
||||
newRequests: make(map[uint64]*state.OracleRequest),
|
||||
}
|
||||
defer o.UpdateHash()
|
||||
|
||||
o.oracleScript = CreateOracleResponseScript(o.Hash)
|
||||
|
||||
|
@ -139,12 +138,17 @@ func newOracle() *Oracle {
|
|||
md = newMethodAndPrice(o.verify, 1<<15, callflag.NoneFlag)
|
||||
o.AddMethod(md, desc)
|
||||
|
||||
o.AddEvent("OracleRequest", manifest.NewParameter("Id", smartcontract.IntegerType),
|
||||
eDesc := newEventDescriptor("OracleRequest", manifest.NewParameter("Id", smartcontract.IntegerType),
|
||||
manifest.NewParameter("RequestContract", smartcontract.Hash160Type),
|
||||
manifest.NewParameter("Url", smartcontract.StringType),
|
||||
manifest.NewParameter("Filter", smartcontract.StringType))
|
||||
o.AddEvent("OracleResponse", manifest.NewParameter("Id", smartcontract.IntegerType),
|
||||
eMD := newEvent(eDesc)
|
||||
o.AddEvent(eMD)
|
||||
|
||||
eDesc = newEventDescriptor("OracleResponse", manifest.NewParameter("Id", smartcontract.IntegerType),
|
||||
manifest.NewParameter("OriginalTx", smartcontract.Hash256Type))
|
||||
eMD = newEvent(eDesc)
|
||||
o.AddEvent(eMD)
|
||||
|
||||
desc = newDescriptor("getPrice", smartcontract.IntegerType)
|
||||
md = newMethodAndPrice(o.getPrice, 1<<15, callflag.ReadStates)
|
||||
|
@ -241,7 +245,11 @@ func (o *Oracle) Metadata() *interop.ContractMD {
|
|||
}
|
||||
|
||||
// Initialize initializes an Oracle contract.
|
||||
func (o *Oracle) Initialize(ic *interop.Context) error {
|
||||
func (o *Oracle) Initialize(ic *interop.Context, hf *config.Hardfork) error {
|
||||
if hf != o.ActiveIn() {
|
||||
return nil
|
||||
}
|
||||
|
||||
setIntWithKey(o.ID, ic.DAO, prefixRequestID, 0)
|
||||
setIntWithKey(o.ID, ic.DAO, prefixRequestPrice, DefaultOracleRequestPrice)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue