github.com/bytom/bytom@v1.1.2-0.20221014091027-bbcba3df6075/protocol/bc/types/block_witness.go (about)

     1  package types
     2  
     3  import (
     4  	"io"
     5  
     6  	"golang.org/x/crypto/ed25519"
     7  
     8  	"github.com/bytom/bytom/encoding/blockchain"
     9  )
    10  
    11  // BlockWitness save the consensus node sign
    12  type BlockWitness []byte
    13  
    14  // Set write the sign data to BlockWitness
    15  func (bw *BlockWitness) Set(data []byte) {
    16  	witness := make([]byte, ed25519.SignatureSize)
    17  	copy(witness, data)
    18  	*bw = witness
    19  }
    20  
    21  func (bw *BlockWitness) readFrom(r *blockchain.Reader) (err error) {
    22  	*bw, err = blockchain.ReadVarstr31(r)
    23  	return err
    24  }
    25  
    26  func (bw *BlockWitness) writeTo(w io.Writer) error {
    27  	_, err := blockchain.WriteVarstr31(w, *bw)
    28  	return err
    29  }