mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-26 04:47:45 +08:00
style(bitswap/message) rename struct
so there's one less name to think about
This commit is contained in:
parent
f94d6a37b6
commit
2c4fefb9d6
@ -27,13 +27,13 @@ type Exportable interface {
|
||||
}
|
||||
|
||||
// message wraps a proto message for convenience
|
||||
type message struct {
|
||||
type impl struct {
|
||||
wantlist map[u.Key]struct{}
|
||||
blocks []blocks.Block
|
||||
}
|
||||
|
||||
func New() BitSwapMessage {
|
||||
return &message{
|
||||
return &impl{
|
||||
wantlist: make(map[u.Key]struct{}),
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,7 @@ func newMessageFromProto(pbm pb.Message) BitSwapMessage {
|
||||
}
|
||||
|
||||
// TODO(brian): convert these into keys
|
||||
func (m *message) Wantlist() []u.Key {
|
||||
func (m *impl) Wantlist() []u.Key {
|
||||
wl := make([]u.Key, 0)
|
||||
for k, _ := range m.wantlist {
|
||||
wl = append(wl, k)
|
||||
@ -60,15 +60,15 @@ func (m *message) Wantlist() []u.Key {
|
||||
}
|
||||
|
||||
// TODO(brian): convert these into blocks
|
||||
func (m *message) Blocks() []blocks.Block {
|
||||
func (m *impl) Blocks() []blocks.Block {
|
||||
return m.blocks
|
||||
}
|
||||
|
||||
func (m *message) AddWanted(k u.Key) {
|
||||
func (m *impl) AddWanted(k u.Key) {
|
||||
m.wantlist[k] = struct{}{}
|
||||
}
|
||||
|
||||
func (m *message) AppendBlock(b blocks.Block) {
|
||||
func (m *impl) AppendBlock(b blocks.Block) {
|
||||
m.blocks = append(m.blocks, b)
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ func FromNet(nmsg netmsg.NetMessage) (BitSwapMessage, error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m *message) ToProto() *pb.Message {
|
||||
func (m *impl) ToProto() *pb.Message {
|
||||
pb := new(pb.Message)
|
||||
for _, k := range m.Wantlist() {
|
||||
pb.Wantlist = append(pb.Wantlist, string(k))
|
||||
@ -92,6 +92,6 @@ func (m *message) ToProto() *pb.Message {
|
||||
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())
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user