-
Notifications
You must be signed in to change notification settings - Fork 15
/
history_plugin.go
160 lines (159 loc) · 4.66 KB
/
history_plugin.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package history_plugin
//type AccountHistoryObject struct {
// ID types.IdType `storm:"id,increment" json:"id"`
// Account common.AccountName `storm:"index"`
// ActionSequenceNum uint64
// AccountSequenceNum int32
// ByAccountActionSeq ByAccountActionSeq `storm:"index"`
// /*ByAccountActionSeq struct {
// Account common.AccountName
// AccountSequenceNum int32
// }`storm:"index"`*/
//}
//
///*search condition*/
//type ByAccountActionSeq struct {
// Account common.AccountName
// AccountSequenceNum int32
//}
//
//type ActionHistoryObject struct {
// ID types.IdType `storm:"id,increment"`
// ActionSequenceNum uint64 `storm:"by_action_sequence_num unique"`
// PackedActionTrace common.HexBytes
// BlockNum uint32
// BlockTime common.BlockTimeStamp
// TrxId common.TransactionIdType
// //c++ no param
// ByTrxId struct {
// TrxId common.TransactionIdType
// ActionSequenceNum uint64
// } `storm:"unique"`
//}
//
//func AddAccountHistoryObject(db *eosiodb.DataBase, aho *AccountHistoryObject) {
// //fmt.Println("params:", aho)
// err := db.Insert(&aho)
// defer db.Close()
// if err != nil {
// fmt.Println(err.Error())
// return
// }
//}
//
//func GetAccountHistoryObjectById(db *eosiodb.DataBase, id types.IdType) {
// result := AccountHistoryObject{}
// err := db.Find("ById", id, &result)
// defer db.Close()
// if err != nil {
// fmt.Println(err.Error())
// return
// }
// //fmt.Println("GetAccountHistoryObjectById result :", result)
//}
//
//func GetAccountByAccountActionSeq(db *eosiodb.DataBase, asNum int32, account common.AccountName) {
//
// aho := AccountHistoryObject{}
// aho.ByAccountActionSeq.AccountSequenceNum = asNum
// aho.ByAccountActionSeq.Account = account
// result := AccountHistoryObject{}
// err := db.Find("condition", aho.ByAccountActionSeq, &result)
// defer db.Close()
// if err != nil {
// fmt.Println(err.Error())
// return
// }
// //fmt.Println("GetAccountByAccActSeq result:", result)
//}
//
//func GetActionHistoryObjectByActSeqNum(db *eosiodb.DataBase, asNum uint64) *ActionHistoryObject {
// result := ActionHistoryObject{}
// err := db.Find("ActionSequenceNum", asNum, &result)
// defer db.Close()
// if err != nil {
// fmt.Println("GetActionHistoryObjectByActSeqNum is error detail :", err.Error())
// }
// return &result
//}
//
//func GetActionHistoryByAccActSeq(db *eosiodb.DataBase, asNum uint64, trxId common.TransactionIdType) {
// result := ActionHistoryObject{}
// result.ByTrxId.TrxId = trxId
// result.ByTrxId.ActionSequenceNum = asNum
// err := db.Find("ByAccountActionSeq", result.ByTrxId, &result)
// defer db.Close()
// if err != nil {
// fmt.Println(err.Error())
// return
// }
// //fmt.Println("result:", result)
//}
//
//func GetAccountHistoryObjectByAccount(db *eosiodb.DataBase, account common.AccountName) *[]AccountHistoryObject {
// aho := AccountHistoryObject{}
// aho.Account = account
// //aho.ByAccountActionSeq.AccountSequenceNum = 4
// fmt.Println("+++++++++++++++++:", aho.ByAccountActionSeq.Account)
// var result []AccountHistoryObject
// err := db.Get("Account", aho.Account, &result)
// defer db.Close()
// if err != nil {
// fmt.Println(err.Error())
// return nil
// }
// //fmt.Print("result :", result)
// return &result
//}
//
//type GetActionParam struct {
// AccountName common.AccountName
// Pos int32
// Offset int32
//}
//
//type OrderedActionResult struct {
// GlobalActionSeq uint64
// AccountActionSeq int32
// BlockNum uint32
// BlockTime common.BlockTimeStamp
// ActionTrace types.ActionTrace
//}
//type GetActionResult struct {
// Actions []OrderedActionResult
// LastIrreversibleBlock uint32
// TimeLimitExceededError bool
//}
//
//func GetActions(params *GetActionParam) *[]GetActionResult {
// //control := chain.GetControlInstance()
// //db := control.DB()
// //chain.get_abi_serializer_max_time
// abiSerializerMaxTime := chain_plugin.GetInstance().GetAbiSerializerMaxTime()
//
// db, err := eosiodb.NewDataBase("./", "shared_memory.bin", true)
// if err != nil {
// fmt.Println("Test_GetAccountHistoryObject is error detail:", err.Error())
// }
// defer db.Close()
//
// ahoList := *GetAccountHistoryObjectByAccount(db, params.AccountName)
// var pageNum, start, end int32
// start = params.Pos
// if start == 0 {
// end = params.Offset //data count per page
// }
// //end = params.Offset+5
// if len(ahoList) > 0 {
// pageNum = int32(len(ahoList)) / end
// }
// //db.Find("ByAccountActionSeq",AccountHistoryObject,[]AccountHistoryObject)
//
// array := ahoList[0:3]
// fmt.Println(array)
//
// fmt.Println(abiSerializerMaxTime, pageNum, start, end)
//
// //return &array
// return nil
//}