/
wire.go
156 lines (146 loc) · 3.87 KB
/
wire.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
package slim
import (
"github.com/QOSGroup/qstars/slim/funcInlocal/ed25519local"
"github.com/tendermint/go-amino"
)
//
//import (
// "github.com/QOSGroup/qbase/account"
// "github.com/QOSGroup/qbase/baseabci"
// "github.com/QOSGroup/qbase/context"
// "github.com/QOSGroup/qbase/mapper"
// "github.com/QOSGroup/qbase/txs"
// "github.com/tendermint/go-amino"
// "github.com/tendermint/tendermint/crypto"
// "github.com/tendermint/tendermint/crypto/ed25519"
// cmn "github.com/tendermint/tendermint/libs/common"
// "log"
// "reflect"
//)
//
type Codec = amino.Codec
func NewCodec() *Codec {
cdc := amino.NewCodec()
return cdc
}
var Cdc *Codec
func init() {
cdc := NewCodec()
RegisterAmino(cdc)
RegisterCodec(cdc)
Cdc = cdc.Seal()
}
// RegisterAmino registers all crypto related types in the given (amino) codec.
func RegisterAmino(cdc *amino.Codec) {
cdc.RegisterInterface((*ed25519local.PubKey)(nil), nil)
cdc.RegisterConcrete(ed25519local.PubKeyEd25519{},
ed25519local.Ed25519PubKeyAminoRoute, nil)
cdc.RegisterInterface((*ed25519local.PrivKey)(nil), nil)
cdc.RegisterConcrete(ed25519local.PrivKeyEd25519{},
ed25519local.Ed25519PrivKeyAminoRoute, nil)
}
func RegisterCodec(cdc *amino.Codec) {
cdc.RegisterConcrete(&Signature{}, "qbase/txs/signature", nil)
cdc.RegisterConcrete(&TxStd{}, "qbase/txs/stdtx", nil)
cdc.RegisterInterface((*ITx)(nil), nil)
cdc.RegisterConcrete(&TxTransfer{}, "qos/txs/TxTransfer", nil)
cdc.RegisterConcrete(&QOSAccount{}, "qbase/account/QOSAccount", nil)
cdc.RegisterConcrete(&BaseAccount{}, "qbase/account/BaseAccount", nil)
cdc.RegisterConcrete(&InvestTx{}, "qstars/InvestTx", nil)
}
// amino codec to marshal/unmarshal
//var typeRegistry = make(map[string]reflect.Type)
//var Cdc *amino.Codec
//
//type ABCICodeType uint32
//type Tags cmn.KVPairs
//
//type QstarsBaseApp struct {
// Transactions BaseXTransaction
// Baseapp *baseabci.BaseApp
// TransactionList []BaseXTransaction
// Logger log.Logger
// RootDir string
//}
//type BaseXTransaction interface {
// mapper.IMapper
// RegisterCdc(cdc *amino.Codec)
// StartX(base *QstarsBaseApp) error
//}
//type Result struct {
//
// // Code is the response code, is stored back on the chain.
// Code ABCICodeType
//
// // Data is any data returned from the app.
// Data []byte
//
// // Log is just debug information. NOTE: nondeterministic.
// Log string
//
// // GasWanted is the maximum units of work we allow this tx to perform.
// GasWanted int64
//
// // GasUsed is the amount of gas actually consumed. NOTE: unimplemented
// GasUsed int64
//
// // Tx fee amount and denom.
// FeeAmount int64
// FeeDenom string
//
// // Tags are used for transaction indexing and pubsub.
// Tags Tags
//}
//
//func MakeCodec() *amino.Codec {
// cdc := MakeQBaseCodec()
// for k, _ := range typeRegistry {
// txs, err := newStruct(k)
// if err == false {
// panic("reflect transaction is error.")
// }
// t := txs.(BaseXTransaction)
// t.RegisterCdc(cdc)
// }
// //kvstore.NewKVStub().RegisterKVCdc(cdc)
// //bank.NewBankStub().RegisterKVCdc(cdc)
// return cdc
//}
//
////
//func newStruct(name string) (interface{}, bool) {
// elem, ok := typeRegistry[name]
// if !ok {
// return nil, false
// }
// return reflect.New(elem).Elem().Interface(), true
//}
//
//func init() {
// Cdc = MakeCodec()
//}
//
//func MakeQBaseCodec() *amino.Codec {
//
// var cdc = amino.NewCodec()
// //RegisterAmino(cdc)
// RegisterCodec(cdc)
//
// return cdc
//}
//
//func RegisterCodec(cdc *amino.Codec) {
// //txs.RegisterCodec(cdc)
// //account.RegisterCodec(cdc)
//}
//func RegisterAmino(cdc *amino.Codec) {
// // These are all written here instead of
// cdc.RegisterInterface((*crypto.PubKey)(nil), nil)
// cdc.RegisterConcrete(ed25519.PubKeyEd25519{},
// "tendermint/PubKeyEd25519", nil)
//
// cdc.RegisterInterface((*crypto.PrivKey)(nil), nil)
// cdc.RegisterConcrete(ed25519.PrivKeyEd25519{},
// "tendermint/PrivKeyEd25519", nil)
//
//}