-
Notifications
You must be signed in to change notification settings - Fork 39
/
p2p.go
37 lines (31 loc) · 915 Bytes
/
p2p.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
package gfspp2p
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/gogoproto/proto"
)
func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&GfSpPing{}, "p2p/Ping", nil)
cdc.RegisterConcrete(&GfSpPong{}, "p2p/Pong", nil)
}
var (
Amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(Amino)
)
func init() {
RegisterCodec(Amino)
}
// GetSignBytes returns the ping message bytes to sign over.
func (m *GfSpPing) GetSignBytes() []byte {
fakeMsg := proto.Clone(m).(*GfSpPing)
fakeMsg.Signature = []byte{}
bz := ModuleCdc.MustMarshalJSON(fakeMsg)
return sdk.MustSortJSON(bz)
}
// GetSignBytes returns the pong message bytes to sign over.
func (m *GfSpPong) GetSignBytes() []byte {
fakeMsg := proto.Clone(m).(*GfSpPong)
fakeMsg.Signature = []byte{}
bz := ModuleCdc.MustMarshalJSON(fakeMsg)
return sdk.MustSortJSON(bz)
}