You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: compact_node_info.go
    path of file: ./repos/cloud-torrent/vendor/github.com/anacrolix/dht/krpc
    
    the code of the file until where you have to start completion: package krpc

import (
	"bytes"
	"encoding/binary"
	"errors"
	"fmt"

	"github.com/anacrolix/torrent/bencode"
)

type CompactIPv4NodeInfo []NodeInfo

var _ bencode.Unmarshaler = &CompactIPv4NodeInfo{}

func (i *CompactIPv4
    
func (i CompactIPv4NodeInfo) MarshalBencode() (ret []byte, err error) {
	var buf bytes.Buffer
	for _, ni := range i {
		buf.Write(ni.ID[:])
		if ni.Addr == nil {
			err = errors.New("nil addr in node info")
			return
		}
		buf.Write(ni.Addr.IP.To4())
		binary.Write(&buf, binary.BigEndian, uint16(ni.Addr.Port))
	}
	return bencode.Marshal(buf.Bytes())
}