candidate: During his regime he faced a French blockade ( 1838–1840 ) , the War of the Confederation ( 1836–1839 ) , and a combined Anglo-French blockade ( 1845–1850 ) , but remained undefeated and prevented further loss of national territory .