Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Blockchain Object #51

Open
AusIV opened this issue Aug 5, 2022 · 0 comments
Open

Expose Blockchain Object #51

AusIV opened this issue Aug 5, 2022 · 0 comments

Comments

@AusIV
Copy link
Contributor

AusIV commented Aug 5, 2022

Rationale

Some plugins would like to be able to get information from the blockchain or even add blocks to the blockchain.

Implementation

The core.Blockchain object is pretty tightly coupled with the Geth codebase, so it will require a wrapper / interface.

In PluGeth utils, create an object with the following interface:

type Blockchain interface{
  func SetHead(head uint64) error
  func SnapSyncCommitHead(hash core.Hash) error
  func Reset() error
  func ResetWithGenesisBlock(genesis []byte) error // RLP encoded *types.Block
  func Export(w io.Writer) error
  func ExportN(w io.Writer, first uint64, last uint64) error
  func Stop()
  func StopInsert()
  func InsertReceiptChain(blockChain [][]byte, receiptChain [][]byte, ancientLimit uint64) (int, error) // List of RLP encoded blocks, list of RLP encoded receipts
  func InsertChain(chain [][]byte) (int, error) // List of RLP encoded blocks
  func InsertBlockWithoutSetHead(block []byte) error // RLP encoded *types.BLock
  func SetChainHead(head []byte) error // RLP encoded *types.Block
  func InsertHeaderChain(chain [][]byte, checkFreq int) (int, error) // List of rlp encoded *types.Header
}

(Comments indicate when []bytes are RLP encoded values)

Then we would need to implement a wrapper object to translate between the types in the above interface and the types required by the *core.BlockChain object. We would then need to expose this to the plugeth backend by way of the Ethereum object in eth/backend.go

heiningair added a commit to heiningair/plugeth that referenced this issue Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant