Check-in [4dba0fcb54]
Overview
Comment:Use a dict for account tracking
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4dba0fcb544aa2220a3208ed4cdb44d630ad1822a80dd82e14ab00a595249530
User & Date: rkeene on 2018-07-03 19:03:10
Other Links: manifest | tags
Context
2018-07-03
19:03
Add support for computing and validating work check-in: 78a7632dc9 user: rkeene tags: trunk
19:03
Use a dict for account tracking check-in: 4dba0fcb54 user: rkeene tags: trunk
06:03
Ensure the correct version of the package is provided check-in: 0938293f53 user: rkeene tags: trunk
Changes

Modified nano.tcl from [8dfa10c41c] to [d4333092df].

649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673

	return [dict get $frontier {*}$args]
}

proc ::nano::account::addPending {account blockHash amount} {
	set accountPubKey [::nano::address::toPublicKey $account -hex]

	set ::nano::account::pending([list $accountPubKey $blockHash]) [dict create amount $amount]
}

proc ::nano::account::receive {account blockHash signKey} {
	set accountPubKey [::nano::address::toPublicKey $account -hex]

	set frontierInfo [getFrontier $account]
	dict with frontierInfo {}

	set blockInfo $::nano::account::pending([list $accountPubKey $blockHash])
	unset ::nano::account::pending([list $accountPubKey $blockHash])

	set amount [dict get $blockInfo amount]
	set blockArgs [list to $account previousBalance $balance \
	                    amount $amount sourceBlock $blockHash \
	                    signKey $signKey representative $representative]

	if {[info exists frontierHash]} {







|








|
|







649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673

	return [dict get $frontier {*}$args]
}

proc ::nano::account::addPending {account blockHash amount} {
	set accountPubKey [::nano::address::toPublicKey $account -hex]

	dict set ::nano::account::pending $accountPubKey $blockHash amount $amount
}

proc ::nano::account::receive {account blockHash signKey} {
	set accountPubKey [::nano::address::toPublicKey $account -hex]

	set frontierInfo [getFrontier $account]
	dict with frontierInfo {}

	set blockInfo [dict get $::nano::account::pending $accountPubKey $blockHash]
	dict unset ::nano::account::pending $accountPubKey $blockHash

	set amount [dict get $blockInfo amount]
	set blockArgs [list to $account previousBalance $balance \
	                    amount $amount sourceBlock $blockHash \
	                    signKey $signKey representative $representative]

	if {[info exists frontierHash]} {
711
712
713
714
715
716
717
718
719
720

721





722
723
724
725
726
727
728
729
730
731
732

	setFrontier $fromAccount $newFrontierHash $newBalance $fromRepresentative
	addPending  $toAccount $newFrontierHash $amount

	return $block
}

proc ::nano::account::receiveAllPending {key} {
	set outBlocks [list]


	set accountPubKey [::nano::key::publicKeyFromPrivateKey $key -hex]






	set signKey [binary encode hex $key]
	set account [::nano::address::fromPublicKey $accountPubKey]

	foreach accountPubKeyBlockHash [array names ::nano::account::pending [list $accountPubKey *]] {
		set blockHash [lindex $accountPubKeyBlockHash 1]
		lappend outBlocks [receive $account $blockHash $signKey]
	}

	return $outBlocks
}







|


>
|
>
>
>
>
>




|
<





711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732

733
734
735
736
737

	setFrontier $fromAccount $newFrontierHash $newBalance $fromRepresentative
	addPending  $toAccount $newFrontierHash $amount

	return $block
}

proc ::nano::account::receiveAllPending {key {accountPubKey ""}} {
	set outBlocks [list]

	if {$accountPubKey eq ""} {
		set accountPubKey [::nano::key::publicKeyFromPrivateKey $key -hex]
	}

	if {![dict exists $::nano::account::pending $accountPubKey]} {
		return $outBlocks
	}

	set signKey [binary encode hex $key]
	set account [::nano::address::fromPublicKey $accountPubKey]

	foreach blockHash [dict keys [dict get $::nano::account::pending $accountPubKey]] {

		lappend outBlocks [receive $account $blockHash $signKey]
	}

	return $outBlocks
}