github.com/braveheart12/insolar-09-08-19@v0.8.7/ledger/storage/record/meta.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  // GenesisRecord is the first record created on storage. It's used to link root objects to it.
    26  type GenesisRecord struct {
    27  }
    28  
    29  // PrevStateID returns previous state id.
    30  func (r *GenesisRecord) PrevStateID() *core.RecordID {
    31  	return nil
    32  }
    33  
    34  // State returns state id.
    35  func (r *GenesisRecord) State() State {
    36  	return StateActivation
    37  }
    38  
    39  // WriteHashData writes record data to provided writer. This data is used to calculate record's hash.
    40  func (r *GenesisRecord) WriteHashData(w io.Writer) (int, error) {
    41  	return w.Write(SerializeRecord(r))
    42  }
    43  
    44  // GetMemory returns state memory.
    45  func (*GenesisRecord) GetMemory() *core.RecordID {
    46  	return nil
    47  }
    48  
    49  // GetImage returns state code.
    50  func (*GenesisRecord) GetImage() *core.RecordRef {
    51  	return nil
    52  }
    53  
    54  // GetIsPrototype returns state code.
    55  func (*GenesisRecord) GetIsPrototype() bool {
    56  	return false
    57  }
    58  
    59  // ChildRecord is a child activation record. Its used for children iterating.
    60  type ChildRecord struct {
    61  	PrevChild *core.RecordID
    62  
    63  	Ref core.RecordRef // Reference to the child's head.
    64  }
    65  
    66  // WriteHashData writes record data to provided writer. This data is used to calculate record's hash.
    67  func (r *ChildRecord) WriteHashData(w io.Writer) (int, error) {
    68  	return w.Write(SerializeRecord(r))
    69  }
    70  
    71  // JetRecord represents Jet.
    72  type JetRecord struct {
    73  	// TODO: should contain prefix.
    74  }
    75  
    76  // WriteHashData writes record data to provided writer. This data is used to calculate record's hash.
    77  func (r *JetRecord) WriteHashData(w io.Writer) (int, error) {
    78  	return w.Write(SerializeRecord(r))
    79  }