Every struct was put in its own file. Every method which is not used
outside the parser package was given package scope. All interfaces were
removed, they are implemented by the structs which are now used
everywhere needed as return values. There is no clear benefit of using
interfaces in this sample.
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
Before when pressing 'ctrl+c' and stopping the go program non of the
deferred functions in listen.go were called. A standard procedure for
stopping goroutines with context was implemented which shuts down the
program gracefully. Logs were added to notify the user that the shutdown
was successful.
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
Created packages for the flat file store and the processor and moved
functions, variables and constants from listener.go to those packages.
Encapsulated everything not used outside the packages, introduced
model.go files which later might be extracted into a model package and
renamed parser/parsedBlock.go to parser/block.go.
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
Added caching util function with tests and applied in:
- parser.Block.Transactions(),
- parser.Payload.ChannelHeader(),
- parser.Payload.SignatureHeader(),
- parser.NamespaceReadWriteSet.ReadWriteSet(),
- parser.EndorserTransaction.ReadWriteSets(),
methods, as it was in the typescript sample.
Corrected Println usage and added comments to util functions.
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
Persisting ledger writes to the file system into the store.log file in
the application-go directory. The write values are converted from bytes
to a string when the read write sets are unwrapped in the transaction
processor.
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
Added block processor struct and the process method.
Implemented getting valid transactions from the last processed index.
Added data structures needed for the store.
Decomposed the parser.Block.Transactions() method into readable chunks.
Added transaction processor struct and process method. Unwrapping
read write set data from the transaction, mapping to a new "write"
data structure and passing down to the store.
Store is an empty function and will be implemented next.
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
Removed Block and Transaction interfaces and unused statusCode function.
Using the struct instead of the interfaces now.
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
Created parser, contract and utils packages and extracted each piece of
functionality into its own files. Removed "Get" prefix from methods and
changed return values from interfaces to structs.
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
Created project structure, fixed typos. Implemented connect.go and
getAllAssets.go. The latter uses an assetTransferBasic struct which
provides a simple API for basic asset operations like create, transfer,
etc.
Added transact.go with some util functions. Using google uuid package to
generate random UUIDs for the transactions.
Implemented pretty printing of JSON results.
Implemented app.go entry point with error handling. The existing
commands are getAllAssets, transact and listen. They can be called from
the command line via: "go run . <command> <command> ...". They will be
executed in order and if a command is not known an the application
panics and aborts before executing any of the commands.
Implementing listen.go. Added checkpointer, context setups, call to
BlockEvents and all the interfaces needed for parsing. Started
implementing the interfaces needed to represent a block bottom up in
structs. Finished NamespaceReadWriteSet, ReadWriteSet and
EndorserTransaction.
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>