Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,3 +607,37 @@ func (s *Silkworm) ExecuteTxn(txCHandle unsafe.Pointer, blockNum uint64, blockHe

return gasUsed, blobGasUsed, fmt.Errorf("silkworm_execute_tx error %d", status)
}

func (s *Silkworm) BlockExecStart(
txCHandle unsafe.Pointer,
blockNum uint64,
blockHeaderHash Hash,
) error {
cTx := (*C.MDBX_txn)(txCHandle)
cBlockNum := C.uint64_t(blockNum)
cBlockHeaderHash := C.CBytes(blockHeaderHash[:])

status := C.silkworm_block_exec_start(s.handle, cTx, cBlockNum, *(*C.struct_SilkwormBytes32)(cBlockHeaderHash))

if status == SILKWORM_OK {
return nil
}

return fmt.Errorf("silkworm_block_exec_end error %d", status)
}

func (s *Silkworm) BlockExecEnd(
txCHandle unsafe.Pointer,
memDbTxHandle unsafe.Pointer,
) error {
cTx := (*C.MDBX_txn)(txCHandle)
memDbTx := (*C.MDBX_txn)(memDbTxHandle)

status := C.silkworm_block_exec_end(s.handle, cTx, memDbTx)

if status == SILKWORM_OK {
return nil
}

return fmt.Errorf("silkworm_block_exec_end error %d", status)
}
15 changes: 15 additions & 0 deletions bindings_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,18 @@ func (s *Silkworm) ExecuteTxn(
) (gasUsed uint64, blobGasUsed uint64, err error) {
return 0, 0, nil
}

func (s *Silkworm) BlockExecStart(
txCHandle unsafe.Pointer,
blockNum uint64,
blockHeaderHash Hash,
) error {
return nil
}

func (s *Silkworm) BlockExecEnd(
txCHandle unsafe.Pointer,
memDbTxHandle unsafe.Pointer,
) error {
return nil
}