github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/acm/acmstate/dump_state.go (about)

     1  package acmstate
     2  
     3  import (
     4  	"bytes"
     5  	"encoding/hex"
     6  	"encoding/json"
     7  
     8  	"github.com/hyperledger/burrow/acm"
     9  	"github.com/hyperledger/burrow/crypto"
    10  )
    11  
    12  type DumpState struct {
    13  	bytes.Buffer
    14  }
    15  
    16  func (dw *DumpState) UpdateAccount(updatedAccount *acm.Account) error {
    17  	dw.WriteString("UpdateAccount\n")
    18  	bs, err := json.Marshal(updatedAccount)
    19  	if err != nil {
    20  		return err
    21  	}
    22  	dw.Write(bs)
    23  	dw.WriteByte('\n')
    24  	return nil
    25  }
    26  
    27  func (dw *DumpState) RemoveAccount(address crypto.Address) error {
    28  	dw.WriteString("RemoveAccount\n")
    29  	dw.WriteString(address.String())
    30  	dw.WriteByte('\n')
    31  	return nil
    32  }
    33  
    34  func (dw *DumpState) SetStorage(address crypto.Address, key, value []byte) error {
    35  	dw.WriteString("SetStorage\n")
    36  	dw.WriteString(address.String())
    37  	dw.WriteByte('/')
    38  	dw.WriteString(hex.EncodeToString(key[:]))
    39  	dw.WriteByte('/')
    40  	dw.WriteString(hex.EncodeToString(value[:]))
    41  	dw.WriteByte('\n')
    42  	return nil
    43  }