// NewMessageBodyStorageReference uses a pre-existing S3 bucket for MessageBody storage.
// Sparta assumes that prexistingBucketName exists and will add an S3::BucketPolicy
// to enable SES PutObject access.
346280
func (perm *SESPermission) NewMessageBodyStorageReference(prexistingBucketName string) (*MessageBodyStorage, error) {
	store := &MessageBodyStorage{}
	store.bucketNameExpr = gocf.String(prexistingBucketName)
	return store, nil
}
1066527
func NewMockStorageV1Interface(ctrl *gomock.Controller) *MockStorageV1Interface {
	mock := &MockStorageV1Interface{ctrl: ctrl}
	mock.recorder = &MockStorageV1InterfaceMockRecorder{mock}
	return mock
}
695273
func NewInitMessage(gf *RawFeatureVector, lf *RawFeatureVector) *Init {
	return &Init{
		GlobalFeatures: gf,
		LocalFeatures:  lf,
	}
}
1336284
func NewNegotiateMessage(domainName, workstationName string) ([]byte, error) {
	payloadOffset := expMsgBodyLen
	flags := defaultFlags

	if domainName != "" {
		flags |= negotiateFlagNTLMSSPNEGOTIATEOEMDOMAINSUPPLIED
	}

	if workstationName != "" {
		flags |= negotiateFlagNTLMSSPNEGOTIATEOEMWORKSTATIONSUPPLIED
	}

	msg := negotiateMessageFields{
		messageHeader:  newMessageHeader(1),
		NegotiateFlags: flags,
		Domain:         newVarField(&payloadOffset, len(domainName)),
		Workstation:    newVarField(&payloadOffset, len(workstationName)),
		Version:        DefaultVersion(),
	}

	b := bytes.Buffer{}
	if err := binary.Write(&b, binary.LittleEndian, &msg); err != nil {
		return nil, err
	}
	if b.Len() != expMsgBodyLen {
		return nil, errors.New("incorrect body length")
	}

	payload := strings.ToUpper(domainName + workstationName)
	if _, err := b.WriteString(payload); err != nil {
		return nil, err
	}

	return b.Bytes(), nil
}
775485
func NewBytesMessage(p level.Priority, b []byte) Composer {
	m := &bytesMessage{
		data: b,
	}

	_ = m.SetPriority(p)

	return m
}
1271022
func NewMockStorageClassInterface(ctrl *gomock.Controller) *MockStorageClassInterface {
	mock := &MockStorageClassInterface{ctrl: ctrl}
	mock.recorder = &MockStorageClassInterfaceMockRecorder{mock}
	return mock
}
666943
func NewMockRefreshTokenStrategy(ctrl *gomock.Controller) *MockRefreshTokenStrategy {
	mock := &MockRefreshTokenStrategy{ctrl: ctrl}
	mock.recorder = &MockRefreshTokenStrategyMockRecorder{mock}
	return mock
}
1125730
func NewInitMessage(connFeatures *lnwire.RawFeatureVector,
	chainHash chainhash.Hash) *Init {

	return &Init{
		ConnFeatures: connFeatures,
		ChainHash:    chainHash,
	}
}
272446
func (o *Buffer) dec_slice_ref_struct_message(p *Properties, base structPointer) error {
	return o.dec_slice_ref_struct(p, false, base)
}
790277
func (o *Buffer) enc_ref_struct_message(p *Properties, base structPointer) error {
	var state errorState
	structp := structPointer_GetRefStructPointer(base, p.field)
	if structPointer_IsNil(structp) {
		return ErrNil
	}

	// Can the object marshal itself?
	if p.isMarshaler {
		m := structPointer_Interface(structp, p.stype).(Marshaler)
		data, err := m.Marshal()
		if err != nil && !state.shouldContinue(err, nil) {
			return err
		}
		o.buf = append(o.buf, p.tagcode...)
		o.EncodeRawBytes(data)
		return nil
	}

	o.buf = append(o.buf, p.tagcode...)
	return o.enc_len_struct(p.stype, p.sprop, structp, &state)
}
550225
func NewMockStorage(ctrl *gomock.Controller) *MockStorage {
	mock := &MockStorage{ctrl: ctrl}
	mock.recorder = &MockStorageMockRecorder{mock}
	return mock
}
150964
func (msg *Message) SetBody(contentType, body string) {
	msg.parts = []part{
		part{
			contentType: contentType,
			body:        bytes.NewBufferString(body),
		},
	}
}
1062362
func (o *Buffer) dec_ref_struct_message(p *Properties, base structPointer) (err error) {
	raw, e := o.DecodeRawBytes(false)
	if e != nil {
		return e
	}

	// If the object can unmarshal itself, let it.
	if p.isUnmarshaler {
		panic("not supported, since this is a pointer receiver")
	}

	obuf := o.buf
	oi := o.index
	o.buf = raw
	o.index = 0

	bas := structPointer_FieldPointer(base, p.field)

	err = o.unmarshalType(p.stype, p.sprop, false, bas)
	o.buf = obuf
	o.index = oi

	return err
}
838798
func (s *UpdateEndpointsBatchOutput) SetMessageBody(v *MessageBody) *UpdateEndpointsBatchOutput {
	s.MessageBody = v
	return s
}
1066339
func NewMessage(mtype messageType, data []byte) *Message {
	return &Message{
		MessageHeader: MessageHeader{
			Version: uint8(2),
			Type:    uint8(mtype),
			DataLen: msgLenToBytes(int64(len(data))),
		},
		Data: data,
	}
}
701603
func migrateGossipMessageStoreKeys(tx *bbolt.Tx) error {
	// We'll start by retrieving the bucket in which these messages are
	// stored within. If there isn't one, there's nothing left for us to do
	// so we can avoid the migration.
	messageStore := tx.Bucket(messageStoreBucket)
	if messageStore == nil {
		return nil
	}

	log.Info("Migrating to the gossip message store new key format")

	// Otherwise we'll proceed with the migration. We'll start by coalescing
	// all the current messages within the store, which are indexed by the
	// public key of the peer which they should be sent to, followed by the
	// short channel ID of the channel for which the message belongs to. We
	// should only expect to find channel announcement signatures as that
	// was the only support message type previously.
	msgs := make(map[[33 + 8]byte]*lnwire.AnnounceSignatures)
	err := messageStore.ForEach(func(k, v []byte) error {
		var msgKey [33 + 8]byte
		copy(msgKey[:], k)

		msg := &lnwire.AnnounceSignatures{}
		if err := msg.Decode(bytes.NewReader(v), 0); err != nil {
			return err
		}

		msgs[msgKey] = msg

		return nil

	})
	if err != nil {
		return err
	}

	// Then, we'll go over all of our messages, remove their previous entry,
	// and add another with the new key format. Once we've done this for
	// every message, we can consider the migration complete.
	for oldMsgKey, msg := range msgs {
		if err := messageStore.Delete(oldMsgKey[:]); err != nil {
			return err
		}

		// Construct the new key for which we'll find this message with
		// in the store. It'll be the same as the old, but we'll also
		// include the message type.
		var msgType [2]byte
		binary.BigEndian.PutUint16(msgType[:], uint16(msg.MsgType()))
		newMsgKey := append(oldMsgKey[:], msgType[:]...)

		// Serialize the message with its wire encoding.
		var b bytes.Buffer
		if _, err := lnwire.WriteMessage(&b, msg, 0); err != nil {
			return err
		}

		if err := messageStore.Put(newMsgKey, b.Bytes()); err != nil {
			return err
		}
	}

	log.Info("Migration to the gossip message store new key format complete!")

	return nil
}
601232
func NewMessageItem(ch string, m *Message) Item {
	return Item{Type: TYPE_MESSAGE, Channel: ch, Message: m}
}