[#787] morph: Return VUB for IR service calls
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
518f3baf41
commit
2393d13e4d
12 changed files with 78 additions and 41 deletions
|
@ -100,6 +100,8 @@ type InvokePrmOptional struct {
|
|||
// It's only used by notary transactions and it affects only the
|
||||
// computation of `validUntilBlock` values.
|
||||
controlTX bool
|
||||
// vub is used to set custom valid until block value.
|
||||
vub uint32
|
||||
}
|
||||
|
||||
// SetHash sets optional hash of the transaction.
|
||||
|
@ -120,6 +122,11 @@ func (i *InvokePrmOptional) IsControl() bool {
|
|||
return i.controlTX
|
||||
}
|
||||
|
||||
// SetVUB sets valid until block value.
|
||||
func (i *InvokePrmOptional) SetVUB(v uint32) {
|
||||
i.vub = v
|
||||
}
|
||||
|
||||
type InvokeRes struct {
|
||||
VUB uint32
|
||||
}
|
||||
|
@ -136,11 +143,11 @@ type InvokeRes struct {
|
|||
func (s StaticClient) Invoke(prm InvokePrm) (InvokeRes, error) {
|
||||
var res InvokeRes
|
||||
var err error
|
||||
var vubP *uint32
|
||||
if s.tryNotary {
|
||||
if s.alpha {
|
||||
var (
|
||||
nonce uint32 = 1
|
||||
vubP *uint32
|
||||
vub uint32
|
||||
err error
|
||||
)
|
||||
|
@ -158,11 +165,19 @@ func (s StaticClient) Invoke(prm InvokePrm) (InvokeRes, error) {
|
|||
vubP = &vub
|
||||
}
|
||||
|
||||
if prm.vub > 0 {
|
||||
vubP = &prm.vub
|
||||
}
|
||||
|
||||
res.VUB, err = s.client.NotaryInvoke(s.scScriptHash, s.fee, nonce, vubP, prm.method, prm.args...)
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.VUB, err = s.client.NotaryInvokeNotAlpha(s.scScriptHash, s.fee, prm.method, prm.args...)
|
||||
if prm.vub > 0 {
|
||||
vubP = &prm.vub
|
||||
}
|
||||
|
||||
res.VUB, err = s.client.NotaryInvokeNotAlpha(s.scScriptHash, s.fee, vubP, prm.method, prm.args...)
|
||||
return res, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue