-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (33 loc) · 1014 Bytes
/
main.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
package main // imports "github.com/fletaio/fleta_testnet"
import (
"log"
"github.com/fletaio/fleta_testnet/common"
"github.com/fletaio/fleta_testnet/core/types"
"github.com/fletaio/fleta_testnet/encoding"
"github.com/fletaio/fleta_testnet/process/vault"
"github.com/fletaio/fleta_testnet/service/p2p"
)
// message types
var (
TransactionMessageType = types.DefineHashedType("p2p.TransactionMessage")
)
func main() {
reg := types.NewRegister(1)
reg.RegisterTransaction(1, &vault.Transfer{})
fc := encoding.Factory("message")
fc.Register(TransactionMessageType, []*p2p.TransactionMessage{})
fct := encoding.Factory("transaction")
t, _ := fct.TypeOf(&vault.Transfer{})
bs, _ := encoding.Marshal([]*p2p.TransactionMessage{
&p2p.TransactionMessage{
ChainID: 1,
Type: t,
Tx: &vault.Transfer{},
Signatures: []common.Signature{common.Signature{1, 2, 3}},
},
})
a := []*p2p.TransactionMessage{}
encoding.Unmarshal(bs, &a)
log.Println(a[0].Signatures[0])
return
}