1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
|
set retval [dict get $retval {*}$args]
}
return $retval
}
proc ::nano::ledger::lmdb::clearPending {lmdbInfo account args} {
set accountPubKey [::nano::address::toPublicKey $account -hex]
}
# Node Configuration
proc ::nano::node::_configDictToJSON {configDict {prefix ""}} {
set values [list]
foreach key [dict keys $configDict] {
set value [dict get $configDict $key]
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
|
set retval [dict get $retval {*}$args]
}
return $retval
}
proc ::nano::ledger::lmdb::clearPending {lmdbInfo account args} {
set accountPubKey [::nano::address::toPublicKey $account -binary]
if {[llength $args] > 1} {
return -code error "wrong # args: clearPending <lmdbInfo> <account> ?<blockHash>?"
}
if {[llength $args] == 1} {
set blockHash [lindex $args 0]
if {[string length $blockHash] != $::nano::block::hashLength} {
set blockHash [binary decode hex $blockHash]
}
set searchKey "${accountPubKey}${blockHash}"
set numberOfRowsDeleted 0
_transaction $lmdbInfo "pending/write" cursor {
while true {
if {[catch {
$cursor getBinary -set $searchKey
} err]} {
if {[string match "ERROR: MDB_NOTFOUND: *" $err]} {
break
}
return -code error $err
}
$cursor del
incr numberOfRowsDeleted
}
}
return $numberOfRowsDeleted
}
set numberOfRowsDeleted 0
set blockHashDict [getPending $lmdbInfo $account]
foreach blockHash [dict keys $blockHashDict] {
incr numberOfRowsDeleted [clearPending $lmdbInfo $account $blockHash]
}
return $numberOfRowsDeleted
}
proc ::nano::ledger::lmdb::addPending {lmdbInfo account blockHash args} {
set accountPubKey [::nano::address::toPublicKey $account -binary]
if {[string length $blockHash] != $::nano::block::hashLength} {
set blockHash [binary decode hex $blockHash]
}
set lmdbKey "${accountPubKey}${blockHash}"
set fromHex [::nano::address::toPublicKey [dict get $args from] -hex]
set amountHex [format %032llx [dict get $args amount]]
set lmdbData [binary format H64H32 $fromHex $amountHex]
_transaction $lmdbInfo "pending/write" cursor {
$cursor putBinary $lmdbKey $lmdbData
}
}
# Node Configuration
proc ::nano::node::_configDictToJSON {configDict {prefix ""}} {
set values [list]
foreach key [dict keys $configDict] {
set value [dict get $configDict $key]
|
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
|
return true
}
proc ::nano::node::setLedgerHandle {handle} {
set procs {
getPending
}
namespace eval ::nano::node::ledger {}
foreach proc $procs {
proc ::nano::node::ledger::$proc args [concat [list tailcall {*}$handle $proc] {{*}$args}]
}
|
>
>
|
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
|
return true
}
proc ::nano::node::setLedgerHandle {handle} {
set procs {
getPending
clearPending
addPending
}
namespace eval ::nano::node::ledger {}
foreach proc $procs {
proc ::nano::node::ledger::$proc args [concat [list tailcall {*}$handle $proc] {{*}$args}]
}
|