1. ์ฃผ์ ๊ธฐ๋ฅ
2. ์ฌ์ฉ ๊ธฐ์
3. ์ํคํ
์ฒ ๋ฐ ํ๋ฆ๋
4. ๊ฐ๋ฐ
โ4-1. ์ฝ๋
โ4-2. ํ๋ฉด
5. ํ๊ฐ
6. ๊ฒฐ๊ณผ
- ์ค๋งํธ ์ปจํธ๋ํธ ์ ๋ก๋
- ์ค๋งํธ ์ปจํธ๋ํธ ๋์๋ณด๋ - ์ค๋งํธ ์ปจํธ๋ํธ ๊ฒ์ / ๋น๊ต
- ์ค๋งํธ ์ปจํธ๋ํธ ์์ธ ์ ๋ณด - ์ค์น / ๋ค์ด๋ก๋ / ํธ๋์ญ์
- ํ๋ก ํธ : React(Typescript)
- ๋ฐฑ์๋ : Gin(Golang)
- ๊ฒ์ ์์ง & ์คํ ๋ฆฌ์ง : Elastic Search
- ๋ธ๋ก์ฒด์ธ : Hyperledger Fabric, Fabric Gateway SDK
- ํ ์คํธ : Jmeter, Postman
| ์ํคํ ์ฒ | ํ๋ฆ๋ |
|---|---|
![]() |
![]() |
func SetConnection() {
log.Println("===============Set Connection ===============")
clientConnection := newGrpcConnection()
//defer clientConnection.Close()
id := newIdentity()
sign := newSign()
gateway, err := client.Connect(
id,
client.WithSign(sign),
client.WithClientConnection(clientConnection),
client.WithEvaluateTimeout(5*time.Second),
client.WithEndorseTimeout(15*time.Second),
client.WithSubmitTimeout(5*time.Second),
client.WithCommitStatusTimeout(1*time.Minute),
)
if err != nil {
panic(err)
}
//defer gateway.Close()
network := gateway.GetNetwork(channelName)
ContractPass = network.GetContract(chaincodeName)
}func TransferAsset(contract *client.Contract, transactionRequest TransactionRequest) string {
log.Println(contract, "2", transactionRequest.AssetID, transactionRequest.NewOwner)
submitResult, commit, err := contract.SubmitAsync("TransferAsset", client.WithArguments(transactionRequest.AssetID, transactionRequest.NewOwner))
if err != nil {
panic(fmt.Errorf("failed to submit transaction asynchronously: %w", err))
}
fmt.Printf("Successfully submitted transaction to transfer ownership from %s to %s. \n", string(submitResult), transactionRequest.NewOwner)
if status, err := commit.Status(); err != nil {
panic(fmt.Errorf("failed to get commit status: %w", err))
} else if !status.Successful {
panic(fmt.Errorf("transaction %s failed to commit with status: %d", status.TransactionID, int32(status.Code)))
}
return string(submitResult)
}type elasticClient struct {
es *elasticsearch.Client
IndexName string
}
type ESResponse struct {
Took int64
Hits struct {
Total struct {
Value int64
}
Hits []*ESHit
}
}
type ESHit struct {
Score float64 `json:"_score"`
Index string `json:"_index"`
Type string `json:"_type"`
Version int64 `json:"_version,omitempty"`
Source Article `json:"_source"`
}
func init() {
cfg := esClientConfig()
es, err := elasticsearch.NewClient(cfg)
if err != nil {
log.Printf("Error creating the client: %s", err)
} else {
log.Println(elasticsearch.Version)
log.Println(es.Info())
}
esClient.es = es
esClient.IndexName = "smart_contract"
}
func esClientConfig() elasticsearch.Config {
cfg := elasticsearch.Config{
Addresses: []string{"https://localhost:9200"},
APIKey: "ZkkwZ2dvWUJvNHBGMlQzZXVGZUU6eGJGaHpTY0JTWC1IU2ZvOTdHTk16QQ==",
CertificateFingerprint: "6a220394bb428259b1991b3dcce16f7a810499de023d5d0bdb97c32bd762ba14",
}
//password : Zh-rgUV*3rdM6NhQE+Bo
return cfg
}func AddDocumentToES(item *Article) (string, error) {
payload, err := json.Marshal(item)
if err != nil {
log.Println(err)
return "", err
}
ctx := context.Background()
req := esapi.IndexRequest{
Index: esClient.IndexName,
DocumentID: string(item.ID),
Body: bytes.NewReader(payload),
Refresh: "true",
}
res, err := req.Do(ctx, esClient.es)
if err != nil {
log.Fatalf("Error getting rsponse: %s", err)
}
defer res.Body.Close()
if res.IsError() {
var e map[string]interface{}
if err := json.NewDecoder(res.Body).Decode(&e); err != nil {
log.Print("payload : ")
log.Println(e)
log.Println(err)
return "", err
}
log.Print(e)
return "", fmt.Errorf("[%s] %s: %s", res.Status(),
e["error"].(map[string]interface{})["type"],
e["error"].(map[string]interface{})["reason"])
}
return "Contract successfully added to search index", nil
}| ์ ๋ณด | |
|---|---|
์ค๋งํธ ์ปจํธ๋ํธ |
![]() |
์ค๋งํธ ์ปจํธ๋ํธ |
![]() |
์ค๋งํธ ์ปจํธ๋ํธ |
![]() |
์ค๋งํธ ์ปจํธ๋ํธ |
![]() |
ํธ๋์ญ์
|
![]() |
๋ณธ ํ๋ก์ ํธ์์๋ ํ์ดํผ๋ ์ ํจ๋ธ๋ฆญ ๋คํธ์ํฌ์ ์ฐ๊ฒฐํ๊ธฐ ์ํด Fabric Gateway SDK๋ฅผ ํ์ฉํ์์ผ๋ฉฐ,
๋ช ๋ น์ด ๊ธฐ๋ฐ ์คํ๊ณผ SDK ๊ธฐ๋ฐ ํธ๋์ญ์ ์ฑ๋ฅ์ ํ๊ฐํ์๋ค.
- SDK
- ํ๋ซํผ๊ณผ ์ฐ๊ฒฐํ๋ ์๊ฐ์ ํฌํจ๋์ง ์์.
- REST API ์์ฒญ ->์๋ต ์ฌ์ด์ ์๊ฐ์ ์ธก์ ํ์์.
- Jmeter๋ฅผ ํ์ฉ
- CLI
- ์๊ฐ ์ธก์ ์ ์๋ฒ์์ CLI๋ฅผ ํตํด ์์คํฌ๋ฆฝํธ์ ์์ฑ๋ ๋ช ๋ น์ด set์ ์คํํ๋ ๊ฒ์ผ๋ก ์์ ์๊ฐ ์ธก์
- ๋ฐ๋ณต๋ฌธ-์์คํฌ๋ฆฝํธ -> ๋์-์์คํฌ๋ฆฝํธ ํํ๋ก ๋ฐ๋ณต ์ํํ์์.
- ๋ฐ์ดํฐ๋ ํ์ดํ๋ผ์ธ์ ํตํด ๊ธฐ๋กํ๊ณ ์ด๋ฅผ ์์คํฌ๋ฆฝํธ๋ฅผ ํตํด min,avg,max ๋ก ์ข ํฉ, ์ ๋ฆฌํจ.
- CLI ์ฒซ ๊ฐ์ latency๊ฐ ๋งค์ฐ ํผ
- ์๋ง connection ๋ฌธ์ ์ผ ๋ฏ, Gateway๋ connection pool์ด ์กด์ฌํจ.
- 99% line์ ๊ฐ๊ณผ maximum๊ฐ์ ์ฐจ์ด๊ฐ ๋งค์ฐ ํผ, ์ด๋ ํ ๊ฐ์ด ๋งค์ฐ ํ์ ์ถ์ธกํ ์ ์์.
- => ๊ฒฐ๊ณผ์ ์ผ๋ก ์ฒซ ๋ฒ์งธ ํ๋ ๊ฐ์ ์ ์ธํ ๋๋จธ์ง๋ค์ ํตํด์ min,avg,max ๊ฐ์ ํ๊ฐํจ.
![]() |
![]() |
์ ์ฒด ๋น๊ต |
์ต๋ |
![]() |
![]() |
ํ๊ท |
์ต์ |
- SDK๊ฐ CLI๋ณด๋ค ์ฑ๋ฅ์ด ๋ฐ์ด๋จ.
- ์ด์
- Fabric Gateway SDK์ ๊ฒฝ์ฐ connection pooling ๋ฐฉ์์ ํตํด ํจ๋ธ๋ฆญ ๋คํธ์ํฌ์ ์ฐ๊ฒฐ๋์ด์์.
- ๊ทธ๋ฌ๋, CLI์ ๊ฒฝ์ฐ ๋งค๋ฒ ๋ ๋ฆฝ์ ์ผ๋ก ์ํ๋๊ธฐ ๋๋ฌธ์ ๋งค๋ฒ ํจ๋ธ๋ฆญ ๋คํธ์ํฌ์ ์ฐ๊ฒฐํ๋ ๊ฒ์ผ๋ก ์ถ์ธก










