mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
fix block size calculation
This commit is contained in:
parent
1ae534ae41
commit
914343c6cc
1 changed files with 11 additions and 6 deletions
|
|
@ -66,7 +66,7 @@ func DecodeWitnessRLP(b []byte) (*types.Block, *Witness, error) {
|
||||||
return &res.block, res.ToWitness(), nil
|
return &res.block, res.ToWitness(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Witness) EncodeRLP(b *types.Block) []byte {
|
func (w *Witness) EncodeRLP() []byte {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
eb := rlp.NewEncoderBuffer(buf)
|
eb := rlp.NewEncoderBuffer(buf)
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ func (w *Witness) EncodeRLP(b *types.Block) []byte {
|
||||||
blockHashes = append(blockHashes, blockHash)
|
blockHashes = append(blockHashes, blockHash)
|
||||||
}
|
}
|
||||||
l := eb.List()
|
l := eb.List()
|
||||||
b.EncodeRLP(eb)
|
w.block.EncodeRLP(eb)
|
||||||
if err := rlp.Encode(eb, root); err != nil {
|
if err := rlp.Encode(eb, root); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -172,12 +172,17 @@ func (w *Witness) Dump() {
|
||||||
|
|
||||||
func (w *Witness) Summary() string {
|
func (w *Witness) Summary() string {
|
||||||
b := new(bytes.Buffer)
|
b := new(bytes.Buffer)
|
||||||
xx, _ := rlp.EncodeToBytes(w.block)
|
xx, err := rlp.EncodeToBytes(w.block)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
totBlock := len(xx)
|
totBlock := len(xx)
|
||||||
|
fmt.Printf("total block size is %d\n", totBlock)
|
||||||
|
|
||||||
|
yy := w.EncodeRLP()
|
||||||
|
|
||||||
yy, _ := rlp.EncodeToBytes(w)
|
|
||||||
totWit := len(yy)
|
totWit := len(yy)
|
||||||
|
fmt.Printf("yy len is %d\n", totWit)
|
||||||
totCode := 0
|
totCode := 0
|
||||||
for _, c := range w.codes {
|
for _, c := range w.codes {
|
||||||
totCode += len(c)
|
totCode += len(c)
|
||||||
|
|
@ -234,7 +239,7 @@ func NewWitness() *Witness {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DumpBlockWithWitnessToFile(w *Witness, b *types.Block) {
|
func DumpBlockWithWitnessToFile(w *Witness, b *types.Block) {
|
||||||
enc := w.EncodeRLP(b)
|
enc := w.EncodeRLP()
|
||||||
path, _ := os.Getwd() //"/datadrive/"
|
path, _ := os.Getwd() //"/datadrive/"
|
||||||
err := os.MkdirAll(fmt.Sprintf("%s/block-dump", path), 0755)
|
err := os.MkdirAll(fmt.Sprintf("%s/block-dump", path), 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue