Skip to content

Commit

Permalink
Merge pull request #3 from erigontech/int_ext_txn_handling
Browse files Browse the repository at this point in the history
MDBX env in ExecuteBlocks for int/ext txn handling
  • Loading branch information
JacekGlen authored Mar 5, 2024
2 parents 8d85f74 + 9873616 commit 028652a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
package silkworm_go

// #cgo CFLAGS: -I${SRCDIR}/include
// #include "silkworm.h"
import "C"

/*
#include "silkworm.h"
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -37,7 +35,7 @@ const (
SILKWORM_INVALID_HANDLE = C.SILKWORM_INVALID_HANDLE
SILKWORM_INVALID_PATH = C.SILKWORM_INVALID_PATH
SILKWORM_INVALID_SNAPSHOT = C.SILKWORM_INVALID_SNAPSHOT
SILKWORM_INVALID_MDBX_TXN = C.SILKWORM_INVALID_MDBX_TXN
SILKWORM_INVALID_MDBX_ENV = C.SILKWORM_INVALID_MDBX_ENV
SILKWORM_INVALID_BLOCK_RANGE = C.SILKWORM_INVALID_BLOCK_RANGE
SILKWORM_BLOCK_NOT_FOUND = C.SILKWORM_BLOCK_NOT_FOUND
SILKWORM_UNKNOWN_CHAIN_ID = C.SILKWORM_UNKNOWN_CHAIN_ID
Expand Down Expand Up @@ -264,6 +262,7 @@ func (s *Silkworm) SentryStop() error {
}

func (s *Silkworm) ExecuteBlocks(
dbEnvCHandle unsafe.Pointer,
txnCHandle unsafe.Pointer,
chainID *big.Int,
startBlock uint64,
Expand All @@ -273,6 +272,7 @@ func (s *Silkworm) ExecuteBlocks(
writeReceipts,
writeCallTraces bool,
) (lastExecutedBlock uint64, err error) {
cEnv := (*C.MDBX_env)(dbEnvCHandle)
cTxn := (*C.MDBX_txn)(txnCHandle)
cChainId := C.uint64_t(chainID.Uint64())
cStartBlock := C.uint64_t(startBlock)
Expand All @@ -285,6 +285,7 @@ func (s *Silkworm) ExecuteBlocks(
cMdbxErrorCode := C.int(0)
status := C.silkworm_execute_blocks(
s.handle,
cEnv,
cTxn,
cChainId,
cStartBlock,
Expand Down
2 changes: 1 addition & 1 deletion bindings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func TestInit(t *testing.T) {
silkworm, err := New(t.TempDir())
silkworm, err := New(t.TempDir(), "")
if err != nil {
t.Error(err)
}
Expand Down

0 comments on commit 028652a

Please sign in to comment.