style(bitswap/message) rename struct
so there's one less name to think about
Brian Tiger Chow committed
Oct 27, 2014 at 06:06 UTC
2c4fefb9d69ce96803994e0ed4b0b41ed3f2b2b7
1 file changed
+8
-8
exchange/bitswap/message/message.go
+8
-8
@@ -27,13 +27,13 @@ type Exportable interface {
27
}
28
29
// message wraps a proto message for convenience
30
-type message struct {
30
+type impl struct {
31
wantlist map[u.Key]struct{}
32
blocks []blocks.Block
33
}
34
35
func New() BitSwapMessage {
36
- return &message{
36
+ return &impl{
37
wantlist: make(map[u.Key]struct{}),
38
}
39
}
@@ -51,7 +51,7 @@ func newMessageFromProto(pbm pb.Message) BitSwapMessage {
51
}
52
53
// TODO(brian): convert these into keys
54
-func (m *message) Wantlist() []u.Key {
54
+func (m *impl) Wantlist() []u.Key {
55
wl := make([]u.Key, 0)
56
for k, _ := range m.wantlist {
57
wl = append(wl, k)
@@ -60,15 +60,15 @@ func (m *message) Wantlist() []u.Key {
60
}
61
62
// TODO(brian): convert these into blocks
63
-func (m *message) Blocks() []blocks.Block {
63
+func (m *impl) Blocks() []blocks.Block {
64
return m.blocks
65
}
66
67
-func (m *message) AddWanted(k u.Key) {
67
+func (m *impl) AddWanted(k u.Key) {
68
m.wantlist[k] = struct{}{}
69
}
70
71
-func (m *message) AppendBlock(b blocks.Block) {
71
+func (m *impl) AppendBlock(b blocks.Block) {
72
m.blocks = append(m.blocks, b)
73
}
74
@@ -81,7 +81,7 @@ func FromNet(nmsg netmsg.NetMessage) (BitSwapMessage, error) {
81
return m, nil
82
}
83
84
-func (m *message) ToProto() *pb.Message {
84
+func (m *impl) ToProto() *pb.Message {
85
pb := new(pb.Message)
86
for _, k := range m.Wantlist() {
87
pb.Wantlist = append(pb.Wantlist, string(k))
@@ -92,6 +92,6 @@ func (m *message) ToProto() *pb.Message {
92
return pb
93
}
94
95
-func (m *message) ToNet(p peer.Peer) (nm.NetMessage, error) {
95
+func (m *impl) ToNet(p peer.Peer) (nm.NetMessage, error) {
96
return nm.FromObject(p, m.ToProto())
97
}