/
types.go
68 lines (61 loc) · 1.42 KB
/
types.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
package manager
import (
"fmt"
"math/big"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/polynetwork/poly/common"
)
var (
quorumGasLimit uint64 = 210000
quorumTxGasPrice = big.NewInt(0)
quorumTxValue = big.NewInt(0)
)
type CrossTransfer struct {
txIndex string
txId []byte
value []byte
toChain uint32
height uint64
}
func (t *CrossTransfer) Serialization(sink *common.ZeroCopySink) {
sink.WriteString(t.txIndex)
sink.WriteVarBytes(t.txId)
sink.WriteVarBytes(t.value)
sink.WriteUint32(t.toChain)
sink.WriteUint64(t.height)
}
func (t *CrossTransfer) Deserialization(source *common.ZeroCopySource) error {
txIndex, eof := source.NextString()
if eof {
return fmt.Errorf("Waiting deserialize txIndex error")
}
txId, eof := source.NextVarBytes()
if eof {
return fmt.Errorf("Waiting deserialize txId error")
}
value, eof := source.NextVarBytes()
if eof {
return fmt.Errorf("Waiting deserialize value error")
}
toChain, eof := source.NextUint32()
if eof {
return fmt.Errorf("Waiting deserialize toChain error")
}
height, eof := source.NextUint64()
if eof {
return fmt.Errorf("Waiting deserialize height error")
}
t.txIndex = txIndex
t.txId = txId
t.value = value
t.toChain = toChain
t.height = height
return nil
}
type QuorumTxInfo struct {
txData []byte
gasLimit uint64
gasPrice *big.Int
contractAddr ethcommon.Address
polyTxHash string
}