+1
-1
go.mod
+1
-1
go.mod
+2
-2
go.sum
+2
-2
go.sum
···
1
1
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
2
2
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
3
-
github.com/atscan/plcbundle v0.2.0 h1:Gfl2fU11e+UsAuOmcf8eqtNiiTEO8mEYkwxvcJb6+lc=
4
-
github.com/atscan/plcbundle v0.2.0/go.mod h1:6MMW993tKm+bsLtaXCzH6m1GU+J1NcjJqMxICoOw08s=
3
+
github.com/atscan/plcbundle v0.3.3 h1:l+Xs9QWM2FDD+Axw+5znRcvfN4czV+F4rBFQaBhg0/0=
4
+
github.com/atscan/plcbundle v0.3.3/go.mod h1:6MMW993tKm+bsLtaXCzH6m1GU+J1NcjJqMxICoOw08s=
5
5
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
6
6
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7
7
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+15
-35
internal/api/handlers.go
+15
-35
internal/api/handlers.go
···
75
75
76
76
// ===== FORMATTING HELPERS =====
77
77
78
-
func formatBundleResponse(bundle *plcbundle.BundleMetadata) map[string]interface{} {
79
-
return map[string]interface{}{
80
-
"plc_bundle_number": bundle.BundleNumber,
81
-
"start_time": bundle.StartTime,
82
-
"end_time": bundle.EndTime,
83
-
"operation_count": plc.BUNDLE_SIZE,
84
-
"did_count": bundle.DIDCount, // Use DIDCount instead of len(DIDs)
85
-
"hash": bundle.Hash,
86
-
"compressed_hash": bundle.CompressedHash,
87
-
"compressed_size": bundle.CompressedSize,
88
-
"uncompressed_size": bundle.UncompressedSize,
89
-
"compression_ratio": float64(bundle.UncompressedSize) / float64(bundle.CompressedSize),
90
-
"cursor": bundle.Cursor,
91
-
"prev_bundle_hash": bundle.PrevBundleHash,
92
-
"created_at": bundle.CreatedAt,
93
-
}
94
-
}
95
-
96
78
func formatEndpointResponse(ep *storage.Endpoint) map[string]interface{} {
97
79
response := map[string]interface{}{
98
80
"id": ep.ID,
···
748
730
"end_time": meta.EndTime,
749
731
"operation_count": meta.OperationCount,
750
732
"did_count": meta.DIDCount,
751
-
"hash": meta.Hash,
733
+
"hash": meta.Hash, // Chain hash (primary)
734
+
"content_hash": meta.ContentHash, // Content hash
735
+
"parent": meta.Parent, // Parent chain hash
752
736
"compressed_hash": meta.CompressedHash,
753
737
"compressed_size": meta.CompressedSize,
754
738
"uncompressed_size": meta.UncompressedSize,
755
739
"compression_ratio": float64(meta.UncompressedSize) / float64(meta.CompressedSize),
756
740
"cursor": meta.Cursor,
757
-
"prev_bundle_hash": meta.PrevBundleHash,
758
741
"created_at": meta.CreatedAt,
759
742
}
760
743
}
···
780
763
"is_upcoming": true,
781
764
"status": "filling",
782
765
"operation_count": count,
766
+
"did_count": stats["did_count"],
783
767
"target_operation_count": 10000,
784
768
"progress_percent": float64(count) / 100.0,
785
769
"operations_needed": 10000 - count,
···
806
790
// Get previous bundle info
807
791
if bundleNum > 1 {
808
792
if prevBundle, err := s.bundleManager.GetBundleMetadata(bundleNum - 1); err == nil {
809
-
result["prev_bundle_hash"] = prevBundle.Hash
793
+
result["parent"] = prevBundle.Hash // Parent chain hash
810
794
result["cursor"] = prevBundle.EndTime.Format(time.RFC3339Nano)
811
795
}
812
796
}
···
1005
989
1006
990
response := make([]map[string]interface{}, len(bundles))
1007
991
for i, bundle := range bundles {
1008
-
response[i] = formatBundleResponse(bundle)
992
+
response[i] = formatBundleMetadata(bundle)
1009
993
}
1010
994
1011
995
resp.json(response)
···
1022
1006
lastBundle := stats["last_bundle"].(int64)
1023
1007
1024
1008
resp.json(map[string]interface{}{
1025
-
"plc_bundle_count": bundleCount,
1026
-
"last_bundle_number": lastBundle,
1027
-
"total_compressed_size": totalSize,
1028
-
"total_compressed_size_mb": float64(totalSize) / 1024 / 1024,
1029
-
"total_compressed_size_gb": float64(totalSize) / 1024 / 1024 / 1024,
1030
-
"total_uncompressed_size": totalUncompressedSize,
1031
-
"total_uncompressed_size_mb": float64(totalUncompressedSize) / 1024 / 1024,
1032
-
"total_uncompressed_size_gb": float64(totalUncompressedSize) / 1024 / 1024 / 1024,
1033
-
"overall_compression_ratio": float64(totalUncompressedSize) / float64(totalSize),
1009
+
"plc_bundle_count": bundleCount,
1010
+
"last_bundle_number": lastBundle,
1011
+
"total_compressed_size": totalSize,
1012
+
"total_uncompressed_size": totalUncompressedSize,
1013
+
"overall_compression_ratio": float64(totalUncompressedSize) / float64(totalSize),
1034
1014
})
1035
1015
}
1036
1016
···
1145
1125
break
1146
1126
}
1147
1127
1148
-
if bundle.PrevBundleHash != prevBundle.Hash {
1128
+
if bundle.Parent != prevBundle.Hash {
1149
1129
valid = false
1150
1130
brokenAt = i
1151
-
errorMsg = fmt.Sprintf("Chain broken: bundle %06d prev_hash doesn't match bundle %06d hash", i, i-1)
1131
+
errorMsg = fmt.Sprintf("Chain broken: bundle %06d parent doesn't match bundle %06d hash", i, i-1)
1152
1132
break
1153
1133
}
1154
1134
}
···
1191
1171
"chain_start_time": firstBundle.StartTime,
1192
1172
"chain_end_time": lastBundleData.EndTime,
1193
1173
"chain_head_hash": lastBundleData.Hash,
1194
-
"first_prev_hash": firstBundle.PrevBundleHash,
1195
-
"last_prev_hash": lastBundleData.PrevBundleHash,
1174
+
"first_parent": firstBundle.Parent,
1175
+
"last_parent": lastBundleData.Parent,
1196
1176
})
1197
1177
}
1198
1178