github.com/braveheart12/insolar-09-08-19@v0.8.7/ledger/storage/record/request.go (about)

     1  /*
     2   *    Copyright 2019 Insolar Technologies
     3   *
     4   *    Licensed under the Apache License, Version 2.0 (the "License");
     5   *    you may not use this file except in compliance with the License.
     6   *    You may obtain a copy of the License at
     7   *
     8   *        http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   *    Unless required by applicable law or agreed to in writing, software
    11   *    distributed under the License is distributed on an "AS IS" BASIS,
    12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   *    See the License for the specific language governing permissions and
    14   *    limitations under the License.
    15   */
    16  
    17  package record
    18  
    19  import (
    20  	"io"
    21  
    22  	"github.com/insolar/insolar/core"
    23  )
    24  
    25  // Request extends Record interface with GetPayload method.
    26  type Request interface {
    27  	Record
    28  	GetPayload() []byte
    29  	GetObject() core.RecordID
    30  }
    31  
    32  // RequestRecord is a contract execution request.
    33  type RequestRecord struct {
    34  	Parcel      []byte
    35  	MessageHash []byte
    36  	Object      core.RecordID
    37  }
    38  
    39  // WriteHashData writes record data to provided writer. This data is used to calculate record's hash.
    40  func (r *RequestRecord) WriteHashData(w io.Writer) (int, error) {
    41  	return w.Write(r.MessageHash)
    42  }
    43  
    44  // GetPayload returns payload. Required for Record interface implementation.
    45  func (r *RequestRecord) GetPayload() []byte {
    46  	return r.Parcel
    47  }
    48  
    49  // GetObject returns request object.
    50  func (r *RequestRecord) GetObject() core.RecordID {
    51  	return r.Object
    52  }