Commit 824a185f authored by Brian Tiger Chow's avatar Brian Tiger Chow

style(bitswap/message) rename struct

so there's one less name to think about
parent a68d9310
...@@ -27,13 +27,13 @@ type Exportable interface { ...@@ -27,13 +27,13 @@ type Exportable interface {
} }
// message wraps a proto message for convenience // message wraps a proto message for convenience
type message struct { type impl struct {
wantlist map[u.Key]struct{} wantlist map[u.Key]struct{}
blocks []blocks.Block blocks []blocks.Block
} }
func New() BitSwapMessage { func New() BitSwapMessage {
return &message{ return &impl{
wantlist: make(map[u.Key]struct{}), wantlist: make(map[u.Key]struct{}),
} }
} }
...@@ -51,7 +51,7 @@ func newMessageFromProto(pbm pb.Message) BitSwapMessage { ...@@ -51,7 +51,7 @@ func newMessageFromProto(pbm pb.Message) BitSwapMessage {
} }
// TODO(brian): convert these into keys // TODO(brian): convert these into keys
func (m *message) Wantlist() []u.Key { func (m *impl) Wantlist() []u.Key {
wl := make([]u.Key, 0) wl := make([]u.Key, 0)
for k, _ := range m.wantlist { for k, _ := range m.wantlist {
wl = append(wl, k) wl = append(wl, k)
...@@ -60,15 +60,15 @@ func (m *message) Wantlist() []u.Key { ...@@ -60,15 +60,15 @@ func (m *message) Wantlist() []u.Key {
} }
// TODO(brian): convert these into blocks // TODO(brian): convert these into blocks
func (m *message) Blocks() []blocks.Block { func (m *impl) Blocks() []blocks.Block {
return m.blocks return m.blocks
} }
func (m *message) AddWanted(k u.Key) { func (m *impl) AddWanted(k u.Key) {
m.wantlist[k] = struct{}{} m.wantlist[k] = struct{}{}
} }
func (m *message) AppendBlock(b blocks.Block) { func (m *impl) AppendBlock(b blocks.Block) {
m.blocks = append(m.blocks, b) m.blocks = append(m.blocks, b)
} }
...@@ -81,7 +81,7 @@ func FromNet(nmsg netmsg.NetMessage) (BitSwapMessage, error) { ...@@ -81,7 +81,7 @@ func FromNet(nmsg netmsg.NetMessage) (BitSwapMessage, error) {
return m, nil return m, nil
} }
func (m *message) ToProto() *pb.Message { func (m *impl) ToProto() *pb.Message {
pb := new(pb.Message) pb := new(pb.Message)
for _, k := range m.Wantlist() { for _, k := range m.Wantlist() {
pb.Wantlist = append(pb.Wantlist, string(k)) pb.Wantlist = append(pb.Wantlist, string(k))
...@@ -92,6 +92,6 @@ func (m *message) ToProto() *pb.Message { ...@@ -92,6 +92,6 @@ func (m *message) ToProto() *pb.Message {
return pb return pb
} }
func (m *message) ToNet(p peer.Peer) (nm.NetMessage, error) { func (m *impl) ToNet(p peer.Peer) (nm.NetMessage, error) {
return nm.FromObject(p, m.ToProto()) return nm.FromObject(p, m.ToProto())
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment