Skip to content
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

tx resource contains operations #863

Merged
merged 4 commits into from
Jan 14, 2019
Merged

Conversation

kfangw
Copy link
Contributor

@kfangw kfangw commented Dec 3, 2018

Github Issue

#862

Background

see #862

Solution

Transaction Resource contains operations

Possible Drawbacks

@codecov-io
Copy link

codecov-io commented Dec 3, 2018

Codecov Report

Merging #863 into master will increase coverage by 1.95%.
The diff coverage is 52.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #863      +/-   ##
==========================================
+ Coverage   58.21%   60.16%   +1.95%     
==========================================
  Files         154      154              
  Lines       10996    11003       +7     
==========================================
+ Hits         6401     6620     +219     
+ Misses       3847     3607     -240     
- Partials      748      776      +28
Flag Coverage Δ
#integration_tests_long_term 44.05% <0%> (?)
#integration_tests_node 40.02% <0%> (-0.03%) ⬇️
#unittests 48.44% <52.94%> (-0.07%) ⬇️
Impacted Files Coverage Δ
lib/node/runner/api/api.go 85% <ø> (+24.28%) ⬆️
lib/node/runner/api/stream.go 42.62% <0%> (-6.91%) ⬇️
lib/node/runner/api/resource/transaction.go 59.45% <100%> (+2.31%) ⬆️
lib/node/runner/api/resource/operation.go 83.33% <100%> (+0.57%) ⬆️
lib/node/runner/api/transaction.go 58.71% <69.56%> (-7.33%) ⬇️
cmd/sebak/cmd/run.go 57.44% <0%> (+0.35%) ⬆️
lib/node/runner/isaac_state_manager.go 94.31% <0%> (+1.42%) ⬆️
lib/node/runner/api_block.go 67.5% <0%> (+1.66%) ⬆️
lib/block/transaction.go 70.12% <0%> (+1.82%) ⬆️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 359ae36...824fd71. Read the comment docs.

@kfangw kfangw changed the title [WIP] tx resource contains operations tx resource contains operations Dec 3, 2018
@kfangw kfangw force-pushed the 862_tx_operations branch 2 times, most recently from bb4157f to 0cf875b Compare December 3, 2018 08:49
@kfangw kfangw self-assigned this Dec 3, 2018
@kfangw kfangw added the API label Dec 3, 2018
@kfangw kfangw force-pushed the 862_tx_operations branch from 0cf875b to 9797c81 Compare December 3, 2018 09:00
Copy link
Contributor Author

@kfangw kfangw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note

@@ -106,27 +103,3 @@ func TriggerEvent(st *storage.LevelDBBackend, transactions []*transaction.Transa
}

}

func renderEventStream(args ...interface{}) ([]byte, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the renderEventStream function is used only by the subscribe API
and it is impossible to get data from storage with this design.
Hence, this function is moved into subscribe API handler and let the function use the closure.

@@ -27,6 +31,7 @@ func (t Transaction) GetMap() hal.Entry {
"sequence_id": t.bt.SequenceID,
"created": t.bt.Created,
"operation_count": len(t.bt.Operations),
"operations": t.tx.B.Operations,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the shape of operation in the transaction resource may differ from operation resource.
But I think that the operation resource will be deprecated and relevant APIs no longer under maintenance.

@kfangw
Copy link
Contributor Author

kfangw commented Dec 3, 2018

review please @spikeekips @anarcher @Geod24

lib/node/runner/api/resource/transaction.go Outdated Show resolved Hide resolved
lib/node/runner/api/resource/transaction.go Outdated Show resolved Hide resolved
lib/node/runner/api/resource/transaction.go Show resolved Hide resolved
lib/node/runner/api/stream.go Outdated Show resolved Hide resolved
}
i := args[1]

if i == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should be folded into line 47 so the error is the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 47 checks the length of arguments
and this line is for checking the first argument value is nil

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but making a difference here does not matter and only looks confusing. Having both checks done together is more consistent.

lib/node/runner/api/stream.go Show resolved Hide resolved
t, hasNext, c := iterFunc()
if !hasNext {
break
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be part of the for condition, instead of infinite loop + break

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a matter of style.
And I was trying to make it for init; cond; after {} style,
the init value is deallocated when the for loop is finished.
I mean, the t is deallocated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, the t is deallocated.

It goes out of scope. But so does it, with the current code. So I don't see the point.

}
payload = resource.NewTransaction(&bt)
return payload, nil
found, err := block.ExistsBlockTransaction(api.storage, key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of exists + get, why don't you get it directly ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To distinguish error in the database and no error but not exist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kfangw kfangw force-pushed the 862_tx_operations branch from b141b77 to c10c002 Compare December 5, 2018 05:37
@kfangw
Copy link
Contributor Author

kfangw commented Dec 6, 2018

Ping @anarcher @spikeekips @Geod24

@kfangw kfangw added the Doc All that Documentation label Dec 7, 2018
@kfangw kfangw requested a review from johndoe0x December 7, 2018 06:56
@kfangw
Copy link
Contributor Author

kfangw commented Dec 7, 2018

@cmcm2222 When this merged, please update the API document according to this change.

@kfangw
Copy link
Contributor Author

kfangw commented Dec 11, 2018

ping @anarcher @Geod24

Copy link
Contributor

@anarcher anarcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kfangw
Copy link
Contributor Author

kfangw commented Dec 12, 2018

@cmcm2222 Could you test this PR and update the Document?
I want to merge this when you are ready for the document.

@kfangw
Copy link
Contributor Author

kfangw commented Dec 18, 2018

@cmcm2222 Could you test this PR and update the Document?
I want to merge this when you are ready for the document.

@cmcm2222 ping

@johndoe0x
Copy link

@kfangw OK. I will check it

Do not use Operation Hash for validation
Identifier the operation is changed to Tx + Index
@kfangw kfangw force-pushed the 862_tx_operations branch from 5daf848 to f89b71e Compare January 10, 2019 06:16
@kfangw kfangw merged commit 6e4cc0f into bosnet:master Jan 14, 2019
@kfangw kfangw deleted the 862_tx_operations branch January 14, 2019 02:05
johndoe0x pushed a commit to bosnet/docs that referenced this pull request Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Doc All that Documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants