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

Push from aleph -> concat #147

Merged
merged 21 commits into from
Jan 4, 2017
Merged

Push from aleph -> concat #147

merged 21 commits into from
Jan 4, 2017

Conversation

yusefnapora
Copy link
Contributor

quick summary:

  • it works!
  • it's ugly
  • it'll get all nice like after the break 😄

@yusefnapora
Copy link
Contributor Author

okay, I think this is in decent shape, although maybe we should merge #146 first, since this branches off of it. I could also do a bit of squashing to sand off some of the edges in the commit history 😄

The last commit adds an ingestSimpleStatement method to the aleph MediachainNode class - it's not as fancy as the mcclient publish in that it doesn't try to do any id extraction, etc. It just takes a namespace, "body" object, refs (and optionally tags + deps). Then adds the serialized object to the datastore and makes + signs a statement and adds it to the DB. It's used in integration_test/push_test.js and seems to be working.

The node's publisher id is currently optional, which isn't ideal... it needs to be generated asynchronously, so you can't make one in the constructor. And I didn't want to make it mandatory since we'll need to update existing usages. The ingest command will fail with an error if it's not set.

Copy link
Contributor

@parkan parkan left a comment

Choose a reason for hiding this comment

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

Let's merge #146 first

.then(() => concatNodeClient())
.then(concat => concat.authorize(alephPeerIdB58, ['scratch.*']))
.catch(err => {
console.error('error during push setup:', err)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really want to catch this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, sorry bout that! I stuck that in when things were failing during setup so I could print a stack trace - need to remove it. well spotted :)

this.db = Levelup(levelOpts)
const location = (options.location == null || options.location === '')
? '/aleph/data-' + uuid.v4()
: options.location
Copy link
Contributor

Choose a reason for hiding this comment

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

const location = options.location || '/aleph/data-' + uuid.v4()

Unless you want number 0, NaN and false to be valid locations?

(there's a moment of wondering if js messes up the precedence in this but it's actually OK)

@yusefnapora yusefnapora changed the title WIP - Push from aleph -> concat Push from aleph -> concat Jan 3, 2017
@parkan
Copy link
Contributor

parkan commented Jan 4, 2017

OK is this ready for final review?

@yusefnapora
Copy link
Contributor Author

I think so; although I realized I don't have a test for a partially-successful push (some valid results + error). I think I'll add that real quick; hopefully it'll work as expected :)

function seedStatementsToAleph (alephNode: AlephNode): Promise<Array<string>> {
return Promise.all(
seedObjects.map(obj =>
alephNode.ingestSimpleStatement('scratch.test', obj, { refs: [obj.id] })
Copy link
Contributor

Choose a reason for hiding this comment

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

one comment here would be towards separating the test flow and the normal flow, i.e. not using ingest* functions to seed test data, but this is probably a separate discussion around testing methodology

@yusefnapora yusefnapora merged commit aed45b2 into master Jan 4, 2017
@yusefnapora yusefnapora deleted the yn-aleph-push branch January 4, 2017 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants