Documentation ¶
Overview ¶
Package dump provides I/O operations for collected states of the Neo smart contracts.
State collection (including storage) allows you to emulate work with "live" contract. First of all, it is in demand for testing. For state reproducibility, it is necessary to be able to persist (dump) information about the contract along with its data, as well as read ready-made dumps.
The package works with dumps stored in the file system using human-readable encoding.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Creator ¶
type Creator struct {
// contains filtered or unexported fields
}
Creator dumps states of the Neo smart contracts. Output file format:
'<label>-<block>-contracts.json': JSON array of contracts' states '<label>-<block>-storage.csv': CSV of contracts' storages
Storage CSV are 'name,key,value' where name stands for contract name and binary key-value are base64-encoded.
Use IterateDumps to access existing dumps.
func NewCreator ¶
NewCreator returns Creator which dumps contracts into given directory. The dump is identified by specified ID. Resulting Creator should be closed when finished working with it.
NewCreator fails if dump with provided ID already exists.
func (*Creator) AddContract ¶
func (x *Creator) AddContract(name string, st state.Contract) *StorageWriter
AddContract adds given state of the named Neo contract to the resulting dump and returns StorageWriter for the contract storage. After all needed contracts are added, they should be flushed via Flush method.
type ID ¶
type ID struct { // Label of the dump source (e.g. testnet, mainnet). Label string // Blockchain height at which the state was pulled. Block uint32 }
ID is a unique identifier of the dump prepared according to the model described in the current package.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads contracts collected in the superior dump.
func (*Reader) IterateContractStates ¶
IterateContractStates iterates over all contracts from the superior dump and passes their states into f.
type StorageWriter ¶
type StorageWriter struct {
// contains filtered or unexported fields
}
StorageWriter writes data into the superior contract's storage dump.
func (*StorageWriter) Write ¶
func (x *StorageWriter) Write(key, value []byte) error
Write saves given binary key-value into the contract dump as storage item.