-
Notifications
You must be signed in to change notification settings - Fork 16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the documentation looks fine (although I haven't thoroughly read the markdown documentation files).
Most of my comments are just addressing questions in the code.
block.go
Outdated
cid "github.com/ipfs/go-cid" | ||
node "github.com/ipfs/go-ipld-format" | ||
mh "github.com/multiformats/go-multihash" | ||
cid "gx/ipfs/QmTprEaAA2A9bst5XH7exuyi5KzNMK3SEDNN8rBDnKWcUS/go-cid" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally don't leave imports in gx form in any repo but go-ipfs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. TIL
: gx-go hook pre-test
and gx-go hook post-test
.
block.go
Outdated
// Copy is NOT IMPLEMENTED YET | ||
// Should return a deep copy of this node. | ||
// TODO | ||
// TBD how deep we want to copy this node. | ||
func (b *EthBlock) Copy() node.Node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigh... The simplest way to do this is to just encode then decode. That gives you a guaranteed copy 😁. I don't think anything will call this so performance shouldn't be that much of an issue.
However, this method really has no place here because IPLD nodes should be immutable once constructed. It's a remanent from the past at this point. Unfortunately, we still have to update the interface (take a look at the issues) and doing that will require quite a bit of cross-project refactoring.
block.go
Outdated
@@ -162,6 +164,7 @@ func (b *EthBlock) MarshalJSON() ([]byte, error) { | |||
return json.Marshal(out) | |||
} | |||
|
|||
// Cid returns the content identifier of the block header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually just abbreviate "content identifier" as CID (kind of like how nobody calls http "hyper-text transport protocol").
block.go
Outdated
@@ -175,18 +178,25 @@ func (b *EthBlock) Cid() *cid.Cid { | |||
return c | |||
} | |||
|
|||
// Parent returns the content identifier of the parent of the block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content identifier -> CID
block.go
Outdated
func (b *EthBlock) Parent() *cid.Cid { | ||
return toCid(MEthBlock, b.header.ParentHash.Bytes()) | ||
} | ||
|
||
// Tx returns the content identifier of the transactionsTrie root of the block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content identifier -> CID
block.go
Outdated
@@ -249,19 +265,27 @@ func (b *EthBlock) ResolveLink(p []string) (*node.Link, []string, error) { | |||
return nil, nil, fmt.Errorf("resolved item was not a link") | |||
} | |||
|
|||
// Size returns the size in bytes of the serialized object | |||
func (b *EthBlock) Size() (uint64, error) { | |||
// TODO: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case you're wondering what this should return... the answer is it doesn't matter. This function will go away as a part of the great go-ipld-format refactor (every IPLD format handles size differently so it's kind of useless at the moment).
block.go
Outdated
func (b *EthBlock) Size() (uint64, error) { | ||
// TODO: | ||
return 0, nil | ||
} | ||
|
||
// Stat helps this struct to comply with the Node interface | ||
// TODO: not sure if stat deserves to stay | ||
func (b *EthBlock) Stat() (*node.NodeStat, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to stay (:sob:) for now but yeah, this will also go away.
trie.go
Outdated
@@ -76,34 +77,39 @@ func NewTrieNode(data []byte) (node.Node, error) { | |||
} | |||
} | |||
|
|||
func (b *TrieNode) Cid() *cid.Cid { | |||
// Cid returns the content identifier of the trie |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content identifier -> CID.
trie.go
Outdated
if err != nil { | ||
panic(err) | ||
} | ||
return c | ||
} | ||
|
||
// HexHash returns the hex hash of the trie |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "hex hash" the standard name for this in etherland?
tx.go
Outdated
type Tx struct { | ||
tx *types.Transaction | ||
} | ||
|
||
func (b *Tx) Cid() *cid.Cid { | ||
// Cid returns the content identifier of the transaction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content identifier -> CID
…. Should be variable in the future
@Stebalien All observations solved. Moving on to the |
block_test.go
Outdated
fmt.Println(c) | ||
|
||
_ = c | ||
// f_ = cmt.Println(c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably be either using this value or not generating it. What's this test for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's legacy code. I planned to improve the test on a later PR. Will delete it now.
block_test.go
Outdated
@@ -63,5 +64,6 @@ func TestBlockWithOddTransactions(t *testing.T) { | |||
t.Fatal(err) | |||
} | |||
|
|||
fmt.Printf("%x\n", blk.Tx().Bytes()) | |||
_ = blk | |||
// fmt.Printf("%x\n", blk.Tx().Bytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. It is legacy code. I'm properly dealing with the tests for block in the next PR.
@Stebalien should we be good to merge this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ah, except I can't merge on this repo... let me ping @whyrusleeping. |
unused
gosimple
staticcheck
golint
plugin
layout.eth-block
to be a block headerrefactor/block-header
.feat/state-trie
.go-ipld-eth-dump-star
, which will be a CLI app where you provide a block hash, and this program will recursively retrieve and add to IPFS block header, ommer list, state trie elements, etc; Until complete the 8 IPLD types. This should be the angular stone to the ambitious project of having the whole eth blockchain on IPFS.go-ethereum
'sethapi
package, to retrieve whatever we need.