// Write out the AdminBlock to binary. func (b *AdminBlock) MarshalBinary() ([]byte, error) { // Marshal all the entries into their own thing (need the size) var buf2 primitives.Buffer for _, v := range b.ABEntries { data, err := v.MarshalBinary() if err != nil { return nil, err } buf2.Write(data) } b.Header.SetMessageCount(uint32(len(b.ABEntries))) b.Header.SetBodySize(uint32(buf2.Len())) data, err := b.Header.MarshalBinary() if err != nil { return nil, err } var buf primitives.Buffer buf.Write(data) // Write the Body out buf.Write(buf2.DeepCopyBytes()) return buf.DeepCopyBytes(), err }