MCPcopy Create free account
hub / github.com/chain/Core / writeContents

Method writeContents

protocol/bc/legacy/output_commitment.go:28–50  ·  view source on GitHub ↗
(w io.Writer, suffix []byte, assetVersion uint64)

Source from the content-addressed store, hash-verified

26}
27
28func (oc *OutputCommitment) writeContents(w io.Writer, suffix []byte, assetVersion uint64) (err error) {
29 if assetVersion == 1 {
30 _, err = oc.AssetAmount.WriteTo(w)
31 if err != nil {
32 return errors.Wrap(err, "writing asset amount")
33 }
34 _, err = blockchain.WriteVarint63(w, oc.VMVersion)
35 if err != nil {
36 return errors.Wrap(err, "writing vm version")
37 }
38 _, err = blockchain.WriteVarstr31(w, oc.ControlProgram)
39 if err != nil {
40 return errors.Wrap(err, "writing control program")
41 }
42 }
43 if len(suffix) > 0 {
44 _, err = w.Write(suffix)
45 if err != nil {
46 return errors.Wrap(err, "writing suffix")
47 }
48 }
49 return nil
50}
51
52func (oc *OutputCommitment) readFrom(r *blockchain.Reader, assetVersion uint64) (suffix []byte, err error) {
53 return blockchain.ReadExtensibleString(r, func(r *blockchain.Reader) error {

Callers 1

writeExtensibleStringMethod · 0.95

Calls 2

WriteToMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected