-
Notifications
You must be signed in to change notification settings - Fork 9
Update Create/CreateBeta method #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pzhao5
wants to merge
9
commits into
master
Choose a base branch
from
pzhao007
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
160dee8
Updat
c70531c
update
d0fac27
Update
416cd72
Updat
48ba68d
update
fe83856
Update
246297a
Merge branch 'pzhao007' of github.com:oysterprotocol/brokernode into …
ccb7b17
u
d3d69c8
update
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,24 +98,21 @@ func SetLogInfoForDatabaseUrl(dbUrl string) { | |
| func SendHttpReq(url string, req interface{}, resp interface{}) error { | ||
| reqJson, err := json.Marshal(req) | ||
| if err != nil { | ||
| LogIfError(err, nil) | ||
| return err | ||
| return LogIfError(err, nil) | ||
| } | ||
| reqBody := bytes.NewBuffer(reqJson) | ||
|
|
||
| httpRes, err := http.Post(url, "application/json", reqBody) | ||
| defer httpRes.Body.Close() // we need to close the connection | ||
|
|
||
| if err != nil { | ||
| LogIfError(err, nil) | ||
| return err | ||
| return LogIfError(err, nil) | ||
| } | ||
|
|
||
| if err := ParseResBody(httpRes, resp); err != nil { | ||
| err = fmt.Errorf("Unable to communicate with Beta node: %v", err) | ||
| // This should consider as BadRequest since the client pick the beta node. | ||
| LogIfError(err, nil) | ||
| return err | ||
| return LogIfError(err, nil) | ||
| } | ||
| return nil | ||
| } | ||
|
|
@@ -256,8 +253,7 @@ func MergeIndexes(a []int, b []int, sectorSize int, numChunks int) ([]int, error | |
| var merged []int | ||
| if len(a) == 0 && len(b) == 0 || len(a) != len(b) { | ||
| err := errors.New("Invalid input for utils.MergeIndexes. Both a []int and b []int must have the same length") | ||
| LogIfError(err, map[string]interface{}{"aInputSize": len(a), "bInputSize": len(b)}) | ||
| return nil, err | ||
| return nil, LogIfError(err, map[string]interface{}{"aInputSize": len(a), "bInputSize": len(b)}) | ||
| } | ||
|
|
||
| for i := 0; i < len(a); i++ { | ||
|
|
@@ -311,9 +307,9 @@ func ConvertGweiToWei(gwei *big.Int) *big.Int { | |
| } | ||
|
|
||
| /*LogIfError logs any error if it is not nil. Allow caller to provide additional freeform info.*/ | ||
| func LogIfError(err error, extraInfo map[string]interface{}) { | ||
| func LogIfError(err error, extraInfo map[string]interface{}) error { | ||
| if err == nil { | ||
| return | ||
| return nil | ||
| } | ||
|
|
||
| fmt.Println(err) | ||
|
|
@@ -325,6 +321,7 @@ func LogIfError(err error, extraInfo map[string]interface{}) { | |
| raven.CaptureError(err, logErrorTags) | ||
| } | ||
| } | ||
| return err | ||
| } | ||
|
|
||
| /* ReturnEncryptedEthKey will be used by several models to encrypt the eth key so we are not storing a naked key */ | ||
|
|
@@ -391,3 +388,37 @@ func IntMax(x, y int) int { | |
| func GenerateBadgerKey(startingString string, genesisHash string, chunkIdx int) string { | ||
| return fmt.Sprintf("%v%v__%d", startingString, genesisHash, chunkIdx) | ||
| } | ||
|
|
||
| /*GetObjectKeyForTreasure will return the treasure key.*/ | ||
| func GetObjectKeyForConfig(genesisHash string) string { | ||
| return fmt.Sprintf("%v/%v", genesisHash, "config") | ||
| } | ||
|
|
||
| /*GetObjectKeyForTreasure will return the treasure key.*/ | ||
| func GetObjectKeyForTreasure(genesisHash string) string { | ||
| return fmt.Sprintf("%v/%v", genesisHash, "treasure_map") | ||
| } | ||
|
|
||
| /*GetObjectKeyForData will return object key for particular data. startIndex is the smallest index in data. */ | ||
| func GetObjectKeyForData(genesisHash string, startIndex int, totalCount int, isReserveIteration bool, batchSize int) string { | ||
| index := 0 | ||
| if isReserveIteration { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit isReverseIteration |
||
| index = (totalCount - 1 - startIndex) / batchSize | ||
| } else { | ||
| index = startIndex / batchSize | ||
| } | ||
|
|
||
| return fmt.Sprintf("%v/%v/%v", genesisHash, "data", index) | ||
| } | ||
|
|
||
| /*GetObjectKeyForHash will return object key for particular data. startIndex is the smallest index in data. */ | ||
| func GetObjectKeyForHash(genesisHash string, startIndex int, totalCount int, isReserveIteration bool, batchSize int) string { | ||
| index := 0 | ||
| if isReserveIteration { | ||
| index = (totalCount - 1 - startIndex) / batchSize | ||
| } else { | ||
| index = startIndex / batchSize | ||
| } | ||
|
|
||
| return fmt.Sprintf("%v/%v/%v", genesisHash, "hash", index) | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.