Merge checkpoint and secure interface with their ES6 classes#73
Merge checkpoint and secure interface with their ES6 classes#73
Conversation
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>
5f89177 to
7fa1ca3
Compare
holgerd77
left a comment
There was a problem hiding this comment.
Looks good, really happy with these changes, this slowly gets to a readable library again! 😄
| super(...args) | ||
| this._scratch = null | ||
| this._checkpoints = [] | ||
| } |
There was a problem hiding this comment.
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) | ||
| } |
There was a problem hiding this comment.
This completes the functionality from the trie class, ok.
| if (!wasCheckpoint && this.isCheckpoint) { | ||
| this._enterCpMode() | ||
| } | ||
| } |
| throw new Error('trying to commit when not checkpointed') | ||
| } | ||
| }) | ||
| } |
|
|
||
| cb() | ||
| }) | ||
| } |
| trie._scratch = this._scratch | ||
| // trie._checkpoints = this._checkpoints.slice() | ||
| return trie | ||
| } |
There was a problem hiding this comment.
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) | ||
| } |
| this.__putDBs = this._putDBs | ||
| this._putDBs = [this._scratch] | ||
| this._putRaw = this.putRaw | ||
| this.putRaw = this._overridePutRaw |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Secure trie functionality also equivalent, ok.
|
One note: this |
This PR merges
checkpointInterfacewithCheckpointTrieandsecureInterfacewithSecureTrie, uses ES6 syntax, and adds some additional comments.CheckpointTrieis moved to its own file, andindex.jssimply exportsCheckpointTrie.