-
Notifications
You must be signed in to change notification settings - Fork 15
/
gen_NodeTransactionIndex.go
148 lines (116 loc) · 3.72 KB
/
gen_NodeTransactionIndex.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
// Code generated by gotemplate. DO NOT EDIT.
package node_transaction
import (
"github.com/eosspark/eos-go/libraries/container"
"github.com/eosspark/eos-go/libraries/multiindex"
"github.com/eosspark/eos-go/plugins/net_plugin/multi_index"
)
// template type MultiIndex(SuperIndex,SuperNode,Value)
type NodeTransactionIndex struct {
super *ById
count int
}
func NewNodeTransactionIndex() *NodeTransactionIndex {
m := &NodeTransactionIndex{}
m.super = &ById{}
m.super.init(m)
return m
}
/*generic class*/
type NodeTransactionIndexNode struct {
super *ByIdNode
}
/*generic class*/
//method for MultiIndex
func (m *NodeTransactionIndex) GetSuperIndex() interface{} { return m.super }
func (m *NodeTransactionIndex) GetFinalIndex() interface{} { return nil }
func (m *NodeTransactionIndex) GetIndex() interface{} {
return nil
}
func (m *NodeTransactionIndex) Size() int {
return m.count
}
func (m *NodeTransactionIndex) Clear() {
m.super.clear()
m.count = 0
}
func (m *NodeTransactionIndex) Insert(v multi_index.NodeTransactionState) bool {
_, res := m.insert(v)
return res
}
func (m *NodeTransactionIndex) insert(v multi_index.NodeTransactionState) (*NodeTransactionIndexNode, bool) {
fn := &NodeTransactionIndexNode{}
n, res := m.super.insert(v, fn)
if res {
fn.super = n
m.count++
return fn, true
}
return nil, false
}
func (m *NodeTransactionIndex) Erase(iter multiindex.IteratorType) {
m.super.erase_(iter)
}
func (m *NodeTransactionIndex) erase(n *NodeTransactionIndexNode) {
m.super.erase(n.super)
m.count--
}
func (m *NodeTransactionIndex) Modify(iter multiindex.IteratorType, mod func(*multi_index.NodeTransactionState)) bool {
return m.super.modify_(iter, mod)
}
func (m *NodeTransactionIndex) modify(mod func(*multi_index.NodeTransactionState), n *NodeTransactionIndexNode) (*NodeTransactionIndexNode, bool) {
defer func() {
if e := recover(); e != nil {
container.Logger.Error("#multi modify failed: %v", e)
m.erase(n)
m.count--
panic(e)
}
}()
mod(n.value())
if sn, res := m.super.modify(n.super); !res {
m.count--
return nil, false
} else {
n.super = sn
return n, true
}
}
func (n *NodeTransactionIndexNode) GetSuperNode() interface{} { return n.super }
func (n *NodeTransactionIndexNode) GetFinalNode() interface{} { return nil }
func (n *NodeTransactionIndexNode) value() *multi_index.NodeTransactionState {
return n.super.value()
}
/// IndexBase
type NodeTransactionIndexBase struct {
final *NodeTransactionIndex
}
type NodeTransactionIndexBaseNode struct {
final *NodeTransactionIndexNode
pv *multi_index.NodeTransactionState
}
func (i *NodeTransactionIndexBase) init(final *NodeTransactionIndex) {
i.final = final
}
func (i *NodeTransactionIndexBase) clear() {}
func (i *NodeTransactionIndexBase) GetSuperIndex() interface{} { return nil }
func (i *NodeTransactionIndexBase) GetFinalIndex() interface{} { return i.final }
func (i *NodeTransactionIndexBase) insert(v multi_index.NodeTransactionState, fn *NodeTransactionIndexNode) (*NodeTransactionIndexBaseNode, bool) {
return &NodeTransactionIndexBaseNode{fn, &v}, true
}
func (i *NodeTransactionIndexBase) erase(n *NodeTransactionIndexBaseNode) {
n.pv = nil
}
func (i *NodeTransactionIndexBase) erase_(iter multiindex.IteratorType) {
container.Logger.Warn("erase iterator doesn't match all index")
}
func (i *NodeTransactionIndexBase) modify(n *NodeTransactionIndexBaseNode) (*NodeTransactionIndexBaseNode, bool) {
return n, true
}
func (i *NodeTransactionIndexBase) modify_(iter multiindex.IteratorType, mod func(*multi_index.NodeTransactionState)) bool {
container.Logger.Warn("modify iterator doesn't match all index")
return false
}
func (n *NodeTransactionIndexBaseNode) value() *multi_index.NodeTransactionState {
return n.pv
}