6 "github.com/bytom/vapor/encoding/blockchain"
9 // BlockWitness save the consensus node sign
10 type BlockWitness struct {
11 // Witness is a vector of arguments for validating this block.
15 func (bw *BlockWitness) readFrom(r *blockchain.Reader) (err error) {
16 bw.Witness, err = blockchain.ReadVarstrList(r)
20 func (bw *BlockWitness) writeTo(w io.Writer) error {
21 _, err := blockchain.WriteVarstrList(w, bw.Witness)
25 // Set save data to index position
26 func (bw *BlockWitness) Set(index uint64, data []byte) {
27 if uint64(len(bw.Witness)) <= index {
28 newWitness := make([][]byte, index+1, index+1)
29 copy(newWitness, bw.Witness)
30 bw.Witness = newWitness
32 bw.Witness[index] = data
35 // Delete remove data from index position
36 func (bw *BlockWitness) Delete(index uint64) {
37 if uint64(len(bw.Witness)) > index {
38 bw.Witness[index] = nil
42 // Get return data from index position
43 func (bw *BlockWitness) Get(index uint64) []byte {
44 if uint64(len(bw.Witness)) > index {
45 return bw.Witness[index]