Skip to content

Commit

Permalink
core/rawdb: REVERTME: notes on ancient ModifyAncients interface
Browse files Browse the repository at this point in the history
Date: 2021-10-13 11:14:53-07:00
Signed-off-by: meows <[email protected]>
  • Loading branch information
meowsbits committed Oct 13, 2021
1 parent 14997f3 commit 9dd8280
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,11 @@ func WriteAncientBlocks(db ethdb.AncientWriter, blocks []*types.Block, receipts
tdSum = new(big.Int).Set(td)
stReceipts []*types.ReceiptForStorage
)
// TODO
// --- Maybe:
// Check if the 'db' is a remote store, then we can use the original AppendAncients method and return.
// Possibly checking for order issues; if out of order, then Truncate and then AppendAncients.
// ---
return db.ModifyAncients(func(op ethdb.AncientWriteOp) error {
for i, block := range blocks {
// Convert receipts to storage format and sum up total difficulty.
Expand Down
18 changes: 16 additions & 2 deletions core/rawdb/freezer_remote_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,23 @@ func (api *FreezerRemoteClient) AppendAncient(number uint64, hash, header, body,
return api.client.Call(nil, FreezerMethodAppendAncient, number, hash, header, body, receipts, td)
}

type freezerBatchRemote struct {
api *FreezerRemoteClient
}

func (b *freezerBatchRemote) Append(kind string, num uint64, item interface{}) error {

return b.api.AppendAncient(num)
}

func (b *freezerBatchRemote) AppendRaw(kind string, num uint64, item []byte) error {

}

// ModifyAncients runs the given write operation.
func (api *FreezerRemoteClient) ModifyAncients(func(ethdb.AncientWriteOp) error) (int64, error) {
// TODO (meowbits | ziogaschr): do we support write operations?
func (api *FreezerRemoteClient) ModifyAncients(fn func(ethdb.AncientWriteOp) error) (int64, error) {
// TODO (meowsbits | ziogaschr): do we support write operations?

return 0, errNotSupported
}

Expand Down

0 comments on commit 9dd8280

Please sign in to comment.