github.com/status-im/status-go@v1.1.0/waku/v1/message_response.go (about)

     1  package v1
     2  
     3  import (
     4  	gethcommon "github.com/ethereum/go-ethereum/common"
     5  	"github.com/ethereum/go-ethereum/rlp"
     6  	"github.com/status-im/status-go/waku/common"
     7  )
     8  
     9  // MultiVersionResponse allows to decode response into chosen version.
    10  type MultiVersionResponse struct {
    11  	Version  uint
    12  	Response rlp.RawValue
    13  }
    14  
    15  // DecodeResponse1 decodes response into first version of the messages response.
    16  func (m MultiVersionResponse) DecodeResponse1() (resp common.MessagesResponse, err error) {
    17  	return resp, rlp.DecodeBytes(m.Response, &resp)
    18  }
    19  
    20  // Version1MessageResponse first version of the message response.
    21  type Version1MessageResponse struct {
    22  	Version  uint
    23  	Response common.MessagesResponse
    24  }
    25  
    26  // NewMessagesResponse returns instance of the version messages response.
    27  func NewMessagesResponse(batch gethcommon.Hash, errors []common.EnvelopeError) Version1MessageResponse {
    28  	return Version1MessageResponse{
    29  		Version: 1,
    30  		Response: common.MessagesResponse{
    31  			Hash:   batch,
    32  			Errors: errors,
    33  		},
    34  	}
    35  }