Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Merge checkpoint and secure interface with their ES6 classes #73

Merged
merged 3 commits into from
Jan 15, 2019

Conversation

s1na
Copy link
Contributor

@s1na s1na commented Jan 15, 2019

This PR merges checkpointInterface with CheckpointTrie and secureInterface with SecureTrie, uses ES6 syntax, and adds some additional comments. CheckpointTrie is moved to its own file, and index.js simply exports CheckpointTrie.

@coveralls
Copy link

coveralls commented Jan 15, 2019

Coverage Status

Coverage decreased (-0.6%) to 93.356% when pulling 7fa1ca3 on refactor/interfaces into 8ee33e1 on master.

s1na added 3 commits January 15, 2019 12:13
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
Signed-off-by: Sina Mahmoodi <itz.s1na@gmail.com>
@s1na s1na force-pushed the refactor/interfaces branch from 5f89177 to 7fa1ca3 Compare January 15, 2019 11:15
Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

Looks good, really happy with these changes, this slowly gets to a readable library again! 😄

super(...args)
this._scratch = null
this._checkpoints = []
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok, this one is the constructor from the old trie class in index.js together with the checkpointInterface instantiation and the isCheckpoint getter from below, looks good.


static verifyProof (...args) {
return proof.verifyProof(...args)
}
Copy link
Member

Choose a reason for hiding this comment

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

This completes the functionality from the trie class, ok.

if (!wasCheckpoint && this.isCheckpoint) {
this._enterCpMode()
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok.

throw new Error('trying to commit when not checkpointed')
}
})
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok.


cb()
})
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok.

trie._scratch = this._scratch
// trie._checkpoints = this._checkpoints.slice()
return trie
}
Copy link
Member

Choose a reason for hiding this comment

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

Was a bit shaky here, but think this is equivalent. Just for the protocol: this method is not tested, we should add a test case at some point.

trie._getDBs = [scratch]
trie._scratch = scratch
return new ScratchReadStream(trie)
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok.

this.__putDBs = this._putDBs
this._putDBs = [this._scratch]
this._putRaw = this.putRaw
this.putRaw = this._overridePutRaw
Copy link
Member

Choose a reason for hiding this comment

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

The former putRaw method in here has been replaced by this _overridePutRaw method, better differentiated, good.


del (key, cb) {
const hash = ethUtil.keccak256(key)
super.del(hash, cb)
Copy link
Member

Choose a reason for hiding this comment

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

Secure trie functionality also equivalent, ok.

@holgerd77 holgerd77 merged commit 029b5fe into master Jan 15, 2019
@holgerd77 holgerd77 deleted the refactor/interfaces branch January 15, 2019 12:08
@holgerd77
Copy link
Member

One note: this checkpoint-trie.js file should actually be renamed to checkpointTrie.js to match baseTrie.js (still a bit inconsistent with secure.js, but better than before and renaming secure.js would change the API). But can be done along some subsequent work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants