-
Notifications
You must be signed in to change notification settings - Fork 0
/
jrpc.go
executable file
·76 lines (62 loc) · 1.83 KB
/
jrpc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package rpc
import (
"context"
"encoding/hex"
"github.com/bnchain/plugin/plugin/dapp/retrieve/types"
)
// CreateRawRetrieveBackupTx construct backup tx
func (c *Jrpc) CreateRawRetrieveBackupTx(in *RetrieveBackupTx, result *interface{}) error {
head := &types.BackupRetrieve{
BackupAddress: in.BackupAddr,
DefaultAddress: in.DefaultAddr,
DelayPeriod: in.DelayPeriod,
}
reply, err := c.cli.Backup(context.Background(), head)
if err != nil {
return err
}
*result = hex.EncodeToString(reply.Data)
return nil
}
// CreateRawRetrievePrepareTx construct prepare tx
func (c *Jrpc) CreateRawRetrievePrepareTx(in *RetrievePrepareTx, result *interface{}) error {
head := &types.PrepareRetrieve{
BackupAddress: in.BackupAddr,
DefaultAddress: in.DefaultAddr,
}
reply, err := c.cli.Prepare(context.Background(), head)
if err != nil {
return err
}
*result = hex.EncodeToString(reply.Data)
return nil
}
// CreateRawRetrievePerformTx construct perform tx
func (c *Jrpc) CreateRawRetrievePerformTx(in *RetrievePerformTx, result *interface{}) error {
head := &types.PerformRetrieve{
BackupAddress: in.BackupAddr,
DefaultAddress: in.DefaultAddr,
}
reply, err := c.cli.Perform(context.Background(), head)
if err != nil {
return err
}
*result = hex.EncodeToString(reply.Data)
return nil
}
// CreateRawRetrieveCancelTx construct cancel tx
func (c *Jrpc) CreateRawRetrieveCancelTx(in *RetrieveCancelTx, result *interface{}) error {
head := &types.CancelRetrieve{
BackupAddress: in.BackupAddr,
DefaultAddress: in.DefaultAddr,
}
reply, err := c.cli.Cancel(context.Background(), head)
if err != nil {
return err
}
*result = hex.EncodeToString(reply.Data)
return nil
}