Skip to content

Commit

Permalink
Merge branch 'sprint-1.11' into test/performance-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitenjain14 authored Dec 13, 2023
2 parents 4f02b0c + d74e39c commit 5ab9207
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
1 change: 0 additions & 1 deletion core/transaction/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ const (
NEW_ALLOCATION_REQUEST = "new_allocation_request"
NEW_FREE_ALLOCATION = "free_allocation_request"
UPDATE_ALLOCATION_REQUEST = "update_allocation_request"
FREE_UPDATE_ALLOCATION = "free_update_allocation"
LOCK_TOKEN = "lock"
UNLOCK_TOKEN = "unlock"

Expand Down
11 changes: 8 additions & 3 deletions zboxcore/sdk/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ func (rb *RollbackBlobber) processRollback(ctx context.Context, tx string) error
wm.AllocationRoot = rb.lpm.PrevWM.AllocationRoot
wm.PreviousAllocationRoot = rb.lpm.PrevWM.AllocationRoot
wm.FileMetaRoot = rb.lpm.PrevWM.FileMetaRoot
if wm.AllocationRoot == rb.lpm.LatestWM.AllocationRoot {
return nil
}
}

err := wm.Sign()
if err != nil {
l.Logger.Error("Signing writemarker failed: ", err)
Expand Down Expand Up @@ -265,7 +269,7 @@ func (a *Allocation) CheckAllocStatus() (AllocStatus, error) {
latestVersion = version
}

if prevVersion == "" {
if prevVersion == "" && version != latestVersion {
prevVersion = version
}

Expand All @@ -276,7 +280,6 @@ func (a *Allocation) CheckAllocStatus() (AllocStatus, error) {
versionMap[version] = append(versionMap[version], rb)
}

l.Logger.Info("versionMap", zap.Any("versionMap", versionMap))
if len(versionMap) < 2 {
return Commit, nil
}
Expand All @@ -290,13 +293,15 @@ func (a *Allocation) CheckAllocStatus() (AllocStatus, error) {
if len(versionMap[latestVersion]) >= req || len(versionMap[prevVersion]) >= req || len(versionMap) > 2 {
// TODO: Return Repair after refactoring the repair function
return Repair, nil
} else {
l.Logger.Info("versionMapLen", zap.Int("versionMapLen", len(versionMap)), zap.Int("latestLen", len(versionMap[latestVersion])), zap.Int("prevLen", len(versionMap[prevVersion])))
}

// rollback to previous version
l.Logger.Info("Rolling back to previous version")
fullConsensus := len(versionMap[latestVersion]) - (req - len(versionMap[prevVersion]))
errCnt = 0

l.Logger.Info("fullConsensus", zap.Int32("fullConsensus", int32(fullConsensus)), zap.Int("latestLen", len(versionMap[latestVersion])), zap.Int("prevLen", len(versionMap[prevVersion])))
for _, rb := range versionMap[latestVersion] {

wg.Add(1)
Expand Down
18 changes: 0 additions & 18 deletions zboxcore/sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1231,24 +1231,6 @@ func UpdateAllocation(
return
}

func CreateFreeUpdateAllocation(marker, allocationId string, value uint64) (string, int64, error) {
if !sdkInitialized {
return "", 0, sdkNotInitialized
}

var input = map[string]interface{}{
"allocation_id": allocationId,
"marker": marker,
}

var sn = transaction.SmartContractTxnData{
Name: transaction.FREE_UPDATE_ALLOCATION,
InputArgs: input,
}
hash, _, n, _, err := smartContractTxnValue(sn, value)
return hash, n, err
}

func FinalizeAllocation(allocID string) (hash string, nonce int64, err error) {
if !sdkInitialized {
return "", 0, sdkNotInitialized
Expand Down
5 changes: 5 additions & 0 deletions zboxcore/sdk/writemarker_mutex.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ func (wmMu *WriteMarkerMutex) lockBlobber(
var resp *http.Response
var shouldContinue bool
for retry := 0; retry < 3; retry++ {
select {
case <-ctx.Done():
return
default:
}
err, shouldContinue = func() (err error, shouldContinue bool) {
reqCtx, ctxCncl := context.WithTimeout(ctx, timeOut)
defer ctxCncl()
Expand Down

0 comments on commit 5ab9207

Please sign in to comment.