-
Notifications
You must be signed in to change notification settings - Fork 15
/
generated_transaction_object.go
52 lines (46 loc) · 1.57 KB
/
generated_transaction_object.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
package entity
import (
"github.com/eosspark/eos-go/chain/types"
"github.com/eosspark/eos-go/common"
"github.com/eosspark/eos-go/common/eos_math"
"github.com/eosspark/eos-go/crypto/rlp"
)
type GeneratedTransactionObject struct {
Id common.IdType `multiIndex:"id,increment,byExpiration,byDelay"`
TrxId common.TransactionIdType `multiIndex:"byTrxId,orderedUnique"`
Sender common.AccountName `multiIndex:"bySenderId,orderedUnique"`
SenderId eos_math.Uint128 `multiIndex:"bySenderId,orderedUnique"`
Payer common.AccountName
DelayUntil common.TimePoint `multiIndex:"byDelay,orderedUnique"`
Expiration common.TimePoint `multiIndex:"byExpiration,orderedUnique"`
Published common.TimePoint
PackedTrx common.HexBytes //c++ shared_string
}
func (g *GeneratedTransactionObject) Set(trx *types.Transaction) uint32 {
g.PackedTrx, _ = rlp.EncodeToBytes(trx)
return uint32(len(g.PackedTrx))
}
type GeneratedTransaction struct {
TrxId common.TransactionIdType
Sender common.AccountName
SenderId eos_math.Uint128
Payer common.AccountName
DelayUntil common.TimePoint
Expiration common.TimePoint
Published common.TimePoint
PackedTrx []byte
}
func GeneratedTransactions(gto *GeneratedTransactionObject) *GeneratedTransaction {
gt := GeneratedTransaction{}
gt.TrxId = gto.TrxId
gt.Sender = gto.Sender
gt.SenderId = gto.SenderId
gt.Payer = gto.Payer
gt.DelayUntil = gto.DelayUntil
gt.Expiration = gto.Expiration
gt.Published = gto.Published
if gto.PackedTrx.Size() > 0 {
gt.PackedTrx = gto.PackedTrx[:]
}
return >
}