Skip to content

Commit

Permalink
refactor: rename bfs to gnfd(GreenField) (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: will-2012-nr <will.nodereal@gmail.com>
  • Loading branch information
will-2012 and xibao-nr authored Jan 31, 2023
1 parent fdf0f01 commit 4b61d32
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GreenField-storage-provider

GreenField-Storage-Provideris storage service infrastructures provided by either organizations or individuals. They use GreenField-Storage-Chain as the ledger and the golden data source of meta. Each SP can and will respond to users’ requests to write (upload) and read (download) data, and be the gatekeeper for user rights and authentications.
GreenField-Storage-Providers storage service infrastructures provided by either organizations or individuals. They use GreenField-Storage-Chain as the ledger and the golden data source of meta. Each SP can and will respond to users’ requests to write (upload) and read (download) data, and be the gatekeeper for user rights and authentications.

# Service
## Build
Expand Down
22 changes: 11 additions & 11 deletions model/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ const (
PutObjectV2Query = "putobjectv2"
ActionQuery = "action"

// bfs header key
BFSRequestIDHeader = "X-Bfs-Request-ID"
BFSContentLengthHeader = "X-Bfs-Content-Length"
BFSContentTypeHeader = "X-Bfs-Content-Type"
BFSChecksumHeader = "X-Bfs-Checksum"
BFSIsPrivateHeader = "X-Bfs-Is-Private"
BFSTransactionHashHeader = "X-Bfs-Txn-Hash"
BFSResourceHeader = "X-Bfs-Resource"
BFSPreSignatureHeader = "X-Bfs-Pre-Signature"
// BFSRedundancyTypeHeader can be EC or Replica, EC is default
BFSRedundancyTypeHeader = "X-Bfs-Redundancy-Type"
// Greenfield header key
GnfdRequestIDHeader = "X-Gnfd-Request-ID"
GnfdContentLengthHeader = "X-Gnfd-Content-Length"
GnfdContentTypeHeader = "X-Gnfd-Content-Type"
GnfdChecksumHeader = "X-Gnfd-Checksum"
GnfdIsPrivateHeader = "X-Gnfd-Is-Private"
GnfdTransactionHashHeader = "X-Gnfd-Txn-Hash"
GnfdResourceHeader = "X-Gnfd-Resource"
GnfdPreSignatureHeader = "X-Gnfd-Pre-Signature"
// GnfdRedundancyTypeHeader can be EC or Replica, EC is default
GnfdRedundancyTypeHeader = "X-Gnfd-Redundancy-Type"

// http header key
ContentTypeHeader = "Content-Type"
Expand Down
4 changes: 2 additions & 2 deletions service/gateway/admin_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ func (g *Gateway) getAuthenticationHandler(w http.ResponseWriter, r *http.Reques
errorDescription = InternalError
return
}
w.Header().Set(model.BFSRequestIDHeader, requestContext.requestID)
w.Header().Set(model.BFSPreSignatureHeader, hex.EncodeToString(info.preSignature))
w.Header().Set(model.GnfdRequestIDHeader, requestContext.requestID)
w.Header().Set(model.GnfdPreSignatureHeader, hex.EncodeToString(info.preSignature))
}
24 changes: 12 additions & 12 deletions service/gateway/object_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ func (g *Gateway) putObjectTxHandler(w http.ResponseWriter, r *http.Request) {
}

// todo: check more params
sizeStr := requestContext.r.Header.Get(model.BFSContentLengthHeader)
sizeStr := requestContext.r.Header.Get(model.GnfdContentLengthHeader)
sizeInt, _ := strconv.Atoi(sizeStr)
isPrivate, _ := strconv.ParseBool(requestContext.r.Header.Get(model.BFSIsPrivateHeader))
isPrivate, _ := strconv.ParseBool(requestContext.r.Header.Get(model.GnfdIsPrivateHeader))
option := &putObjectTxOption{
requestContext: requestContext,
objectSize: uint64(sizeInt),
contentType: requestContext.r.Header.Get(model.BFSContentTypeHeader),
checksum: []byte(requestContext.r.Header.Get(model.BFSChecksumHeader)),
contentType: requestContext.r.Header.Get(model.GnfdContentTypeHeader),
checksum: []byte(requestContext.r.Header.Get(model.GnfdChecksumHeader)),
isPrivate: isPrivate,
redundancyType: requestContext.r.Header.Get(model.BFSRedundancyTypeHeader),
redundancyType: requestContext.r.Header.Get(model.GnfdRedundancyTypeHeader),
}
info, err := g.uploadProcessor.putObjectTx(requestContext.objectName, option)
if err != nil {
Expand All @@ -77,8 +77,8 @@ func (g *Gateway) putObjectTxHandler(w http.ResponseWriter, r *http.Request) {
return
}
// succeed ack
w.Header().Set(model.BFSRequestIDHeader, requestContext.requestID)
w.Header().Set(model.BFSTransactionHashHeader, hex.EncodeToString(info.txHash))
w.Header().Set(model.GnfdRequestIDHeader, requestContext.requestID)
w.Header().Set(model.GnfdTransactionHashHeader, hex.EncodeToString(info.txHash))
}

// putObjectHandler handle put object request, include steps:
Expand Down Expand Up @@ -124,7 +124,7 @@ func (g *Gateway) putObjectHandler(w http.ResponseWriter, r *http.Request) {
errorDescription = UnauthorizedAccess
return
}
txHash, err := hex.DecodeString(requestContext.r.Header.Get(model.BFSTransactionHashHeader))
txHash, err := hex.DecodeString(requestContext.r.Header.Get(model.GnfdTransactionHashHeader))
if err != nil && len(txHash) != hash.LengthHash {
errorDescription = InvalidTxHash
return
Expand All @@ -145,7 +145,7 @@ func (g *Gateway) putObjectHandler(w http.ResponseWriter, r *http.Request) {
errorDescription = InternalError
return
}
w.Header().Set(model.BFSRequestIDHeader, requestContext.requestID)
w.Header().Set(model.GnfdRequestIDHeader, requestContext.requestID)
w.Header().Set(model.ETagHeader, info.eTag)
}

Expand Down Expand Up @@ -249,7 +249,7 @@ func (g *Gateway) putObjectV2Handler(w http.ResponseWriter, r *http.Request) {
return
}

txHash, err := hex.DecodeString(requestContext.r.Header.Get(model.BFSTransactionHashHeader))
txHash, err := hex.DecodeString(requestContext.r.Header.Get(model.GnfdTransactionHashHeader))
if err != nil && len(txHash) != hash.LengthHash {
errorDescription = InvalidTxHash
return
Expand All @@ -261,7 +261,7 @@ func (g *Gateway) putObjectV2Handler(w http.ResponseWriter, r *http.Request) {
requestContext: requestContext,
txHash: txHash,
size: uint64(sizeInt),
redundancyType: requestContext.r.Header.Get(model.BFSRedundancyTypeHeader),
redundancyType: requestContext.r.Header.Get(model.GnfdRedundancyTypeHeader),
}

info, err := g.uploadProcessor.putObjectV2(requestContext.objectName, r.Body, option)
Expand All @@ -278,6 +278,6 @@ func (g *Gateway) putObjectV2Handler(w http.ResponseWriter, r *http.Request) {
errorDescription = InternalError
return
}
w.Header().Set(model.BFSRequestIDHeader, requestContext.requestID)
w.Header().Set(model.GnfdRequestIDHeader, requestContext.requestID)
w.Header().Set(model.ETagHeader, info.eTag)
}
2 changes: 1 addition & 1 deletion service/gateway/request_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func newRequestContext(r *http.Request) *requestContext {
bucket string
object string
)
bucket = r.Header.Get(model.BFSResourceHeader)
bucket = r.Header.Get(model.GnfdResourceHeader)
fields := strings.Split(bucket, "/")
if len(fields) >= 2 {
bucket = fields[0]
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/services/case_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func runCase1() {
log.Errorw("get auth failed, due to new request", "error", err)
return
}
req.Header.Add(model.BFSResourceHeader, "test_bucket/case1")
req.Header.Add(model.GnfdResourceHeader, "test_bucket/case1")
res, err := client.Do(req)
if err != nil {
log.Errorw("get auth failed, due to send request", "error", err)
Expand Down Expand Up @@ -75,7 +75,7 @@ func runCase1() {
return
}
req.Host = "test_bucket.bfs.nodereal.com"
req.Header.Add(model.BFSTransactionHashHeader, generateRandString(64))
req.Header.Add(model.GnfdTransactionHashHeader, generateRandString(64))
req.Header.Add(model.ContentLengthHeader, "1")
res, err := client.Do(req)
if err != nil {
Expand Down Expand Up @@ -130,7 +130,7 @@ func runCase2() {
log.Errorw("get auth failed, due to new request", "error", err)
return
}
req.Header.Add(model.BFSResourceHeader, "test_bucket/case2")
req.Header.Add(model.GnfdResourceHeader, "test_bucket/case2")
res, err := client.Do(req)
if err != nil {
log.Errorw("get auth failed, due to send request", "error", err)
Expand Down Expand Up @@ -162,9 +162,9 @@ func runCase2() {
return
}
req.Host = "test_bucket.bfs.nodereal.com"
req.Header.Add(model.BFSTransactionHashHeader, generateRandString(64))
req.Header.Add(model.GnfdTransactionHashHeader, generateRandString(64))
req.Header.Add(model.ContentLengthHeader, "67108864")
req.Header.Add(model.BFSRedundancyTypeHeader, model.ReplicaRedundancyTypeHeaderValue)
req.Header.Add(model.GnfdRedundancyTypeHeader, model.ReplicaRedundancyTypeHeaderValue)
res, err := client.Do(req)
if err != nil {
log.Errorw("put object failed, due to send request", "error", err)
Expand Down Expand Up @@ -219,7 +219,7 @@ func runCase3() {
log.Errorw("get auth failed, due to new request", "error", err)
return
}
req.Header.Add(model.BFSResourceHeader, "test_bucket/case3")
req.Header.Add(model.GnfdResourceHeader, "test_bucket/case3")
res, err := client.Do(req)
if err != nil {
log.Errorw("get auth failed, due to send request", "error", err)
Expand Down Expand Up @@ -251,7 +251,7 @@ func runCase3() {
return
}
req.Host = "test_bucket.bfs.nodereal.com"
req.Header.Add(model.BFSTransactionHashHeader, generateRandString(64))
req.Header.Add(model.GnfdTransactionHashHeader, generateRandString(64))
req.Header.Add(model.ContentLengthHeader, "209715200")
res, err := client.Do(req)
if err != nil {
Expand Down

0 comments on commit 4b61d32

Please sign in to comment.