mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
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>
45 lines
903 B
Go
45 lines
903 B
Go
/*
|
|
* Copyright 2024 IBM All Rights Reserved.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
package contract
|
|
|
|
import (
|
|
"offChainData/utils"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
var (
|
|
colors = []string{"red", "green", "blue"}
|
|
Owners = []string{"alice", "bob", "charlie"}
|
|
)
|
|
|
|
const (
|
|
maxInitialValue = 1000
|
|
maxInitialSize = 10
|
|
)
|
|
|
|
type Asset struct {
|
|
ID string `json:"ID"`
|
|
Color string `json:"Color"`
|
|
Size uint64 `json:"Size"`
|
|
Owner string `json:"Owner"`
|
|
AppraisedValue uint64 `json:"AppraisedValue"`
|
|
}
|
|
|
|
func NewAsset() Asset {
|
|
id, err := uuid.NewRandom()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return Asset{
|
|
ID: id.String(),
|
|
Color: utils.RandomElement(colors),
|
|
Size: uint64(utils.RandomInt(maxInitialSize) + 1),
|
|
Owner: utils.RandomElement(Owners),
|
|
AppraisedValue: uint64(utils.RandomInt(maxInitialValue) + 1),
|
|
}
|
|
}
|